Math calculator

Prime Gap Calculator

Measure the distance between the nearest prime below and nearest prime above an integer. Each submitted value produces prime gap plus the intermediate reasoning.

Prime Gap inputs

Start with the given values

Conditions that alter Prime Gap

The convention at a prime input matters; this calculator uses that prime as the lower endpoint. Very large searches are restricted to safe integers.

Prime gaps describe how irregularly primes occupy the number line and help compare the search range around a proposed modulus. A related application of Prime Gap is previous prime.

Around 100, the neighboring primes are 97 and 101. Their difference is four. This Prime Gap example can be compared with classify the input.

Saving enough detail for Prime Gap

Before accepting Prime gap, restore the Prime Gap inputs Integer between the primes and the fixed condition. Estimate Prime gap independently. Then vary the fixed condition alone and observe the new Prime Gap output. This isolates the changed part of Prime Gap.

Find the lower prime at or below the input and the first prime above it, then subtract the lower endpoint from the upper endpoint.

The role of Prime Gap in a larger problem

Choosing a useful form for Prime Gap

A local prime gap is the difference between consecutive primes that surround the chosen location. If the input itself is prime, this page reports the gap from that prime to the next one. Prime Gap also connects with next prime.

Reading the endpoints

A gap should be recorded with its endpoint primes, not only as a width. The value four could describe 7 to 11, 13 to 17, or many later pairs. Keeping both endpoints makes the result reproducible and clarifies whether the chosen input was itself the lower prime.

Testing Prime Gap beyond the example

Keep Integer between the primes integral when Prime Gap requires integers. Verify the result through the defining Prime Gap identity.

Test zero in Prime Gap, then test one in Prime Gap. Rebuild the starting integer through Prime Gap.

Cross-checking Prime Gap

Test Prime Gap with a round value for Integer between the primes. Keep the fixed condition fixed and estimate Prime gap before recalculating. The estimated Prime gap gives the original Prime Gap answer a scale check, while the unchanged the fixed condition makes the comparison meaningful.

Validating Prime Gap

Vary Integer between the primes alone to test Prime Gap sensitivity. Freeze the fixed condition and watch Prime gap. Several simultaneous edits would hide which part of the Prime Gap setup caused the change in Prime gap.

Questions about Prime Gap

Are twin primes a gap of two?

Yes.

Is every prime gap even?

After the gap from 2 to 3, consecutive odd primes differ by an even number.

Can prime gaps grow arbitrarily large?

Yes.