Problem 42914. Counting the Grand Primes
A grand prime pair is a pair of primes, p1 and p2=p1+1000, such that both numbers are prime. Like a twin prime pair, where the difference is 2, the members of a grand prime pair always have a difference of 1000. Some facts about grand prime pairs, so that you can test your code:
1. The smallest grand prime pair is [13,1013], the 100th such pair is [3229,4229].
2. There are 37 grand prime pairs such that the larger element of the pair is no larger than 2000.
3. There should be infinitely many grand prime pairs.
4. All such grand prime pairs must have the property that the smaller element of the pair is of the form 6*k+1, for some integer k.
Write a function that counts the number of grand prime pairs that exist, such that the larger element of the pair is no larger than N. I'll be nice and not ask you to compute that result for N too large, 1e8 seems a reasonable upper limit.
Solution Stats
Problem Comments
Solution Comments
Show commentsProblem Recent Solvers50
Suggested Problems
-
"Low : High - Low : High - Turn around " -- Create a subindices vector
544 Solvers
-
Find the maximum number of decimal places in a set of numbers
2958 Solvers
-
Calculate the area of a triangle between three points
3110 Solvers
-
8768 Solvers
-
174 Solvers
More from this Author4
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!