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
-
Find all elements less than 0 or greater than 10 and replace them with NaN
15531 Solvers
-
Find relatively common elements in matrix rows
2051 Solvers
-
Maximum running product for a string of numbers
2162 Solvers
-
Convert a numerical matrix into a cell array of strings
1832 Solvers
-
1558 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!