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?
clc
p=primes(9999999); prev=0;ct=0;
g=p(2:end)-p(1:end-1);
for i=1:length(g)
if g(i)==prev && prev>2
fprintf('%8d %8d %3d ',[pnos p(i),p(i+1) p(i+1)-p(i)])
fprintf('\n')
ct=ct+1;
if ct>=30
break
end
end
prev=g(i);
pnos=[p(i),p(i+1) p(i+1)-p(i)];
end
The first such larger gap is of 6, between 47 and 53 and between 53 and 59:
47 53 6 53 59 6
151 157 6 157 163 6
167 173 6 173 179 6
199 211 12 211 223 12
251 257 6 257 263 6
257 263 6 263 269 6
367 373 6 373 379 6
557 563 6 563 569 6
587 593 6 593 599 6
601 607 6 607 613 6
647 653 6 653 659 6
727 733 6 733 739 6
941 947 6 947 953 6
971 977 6 977 983 6
1097 1103 6 1103 1109 6
1117 1123 6 1123 1129 6
1181 1187 6 1187 1193 6
1217 1223 6 1223 1229 6
1361 1367 6 1367 1373 6
1499 1511 12 1511 1523 12
1741 1747 6 1747 1753 6
1747 1753 6 1753 1759 6
1901 1907 6 1907 1913 6
2281 2287 6 2287 2293 6
2411 2417 6 2417 2423 6
2671 2677 6 2677 2683 6
2897 2903 6 2903 2909 6
2957 2963 6 2963 2969 6
3301 3307 6 3307 3313 6
3307 3313 6 3313 3319 6
|
Posted by Charlie
on 2024-12-24 08:47:23 |