All about flooble | fun stuff | Get a free chatterbox | Free JavaScript | Avatars    
perplexus dot info

Home > Just Math
Prime gaps (Posted on 2024-12-24) Difficulty: 2 of 5
The first prime gap of 2 is between 3 and 5. This is followed by another gap of 2 between 5 and 7. What number n>2 has the property that the first prime gap of n is followed by another gap of n?

No Solution Yet Submitted by Math Man    
No Rating

Comments: ( Back to comment list | You must be logged in to post comments.)
Solution Different Interpretation Comment 3 of 3 |
My interpretation of the problem is not just to find 3 consecutive primes such that the two gaps are the same, but also that these will be the first and second instances of that particular prime gap size.

So, for example 23 to 29 is the first instance of a gap of 6.  But it is followed by 31 and a gap of 2.  So the first prime gap of 6 is not followed by another gap of 6.

My solution:
3 primes         2 gaps
3 5 7                 2 2
199 211 223    12 12

n = 12

----------
import sympy as s
gaps = {}
prior = 2
for n in range(10000):
    new = s.nextprime(prior)
    gap = new - prior
    if gap not in gaps:
        future = s.nextprime(new)
        futuregap = future - new
        gaps[gap] = [new, futuregap]
        if gap == futuregap:
            print(prior, new, future, '  ', gap, futuregap)
    prior = new

  Posted by Larry on 2024-12-24 11:38:24
Please log in:
Login:
Password:
Remember me:
Sign up! | Forgot password


Search:
Search body:
Forums (0)
Newest Problems
Random Problem
FAQ | About This Site
Site Statistics
New Comments (1)
Unsolved Problems
Top Rated Problems
This month's top
Most Commented On

Chatterbox:
Copyright © 2002 - 2024 by Animus Pactum Consulting. All rights reserved. Privacy Information