Math Is Fun Forum

  Discussion about math, puzzles, games and fun.   Useful symbols: ÷ × ½ √ ∞ ≠ ≤ ≥ ≈ ⇒ ± ∈ Δ θ ∴ ∑ ∫ • π ƒ -¹ ² ³ °

You are not logged in.

#1 2014-12-07 05:04:48

Stangerzv
Member
Registered: 2012-01-30
Posts: 266

Max Number of Consecutive Primes

Consider this equation.

Where n is an even number, (n-1) should be prime and

is a consecutive Prime and s is a constant (also a prime).

Let n=4, yields


So far, the max number of consecutive prime formed is 6 for s<1,000,000

Last edited by Stangerzv (2014-12-07 06:17:54)

Offline

#2 2014-12-07 05:08:28

Stangerzv
Member
Registered: 2012-01-30
Posts: 266

Re: Max Number of Consecutive Primes

For n=6

Max number of consecutive primes is 6 for s<1,500,000

Last edited by Stangerzv (2014-12-07 05:58:33)

Offline

#3 2014-12-07 14:08:52

Stangerzv
Member
Registered: 2012-01-30
Posts: 266

Re: Max Number of Consecutive Primes

It seems for max consecutive primes for all n and s is 6.

Offline

#4 2014-12-07 16:12:40

Stangerzv
Member
Registered: 2012-01-30
Posts: 266

Re: Max Number of Consecutive Primes

Smallest solution for

s=1373th Prime{ 11369}, Pr=34141
s=1374th Prime {11383}, Pr=34183
s=1375th Prime {11393}, Pr=34213
s=1376th Prime {11399}, Pr=34231
s=1377th Prime {11411}, Pr=34267
s=1378th Prime {11423}, Pr=34303

Offline

#5 2014-12-08 20:22:29

Stangerzv
Member
Registered: 2012-01-30
Posts: 266

Re: Max Number of Consecutive Primes

There are plenty of four consecutive primes. Setting s to non-primes would make a single consecutive prime very rare or non-existence.

Offline

#6 2014-12-09 13:16:39

Stangerzv
Member
Registered: 2012-01-30
Posts: 266

Re: Max Number of Consecutive Primes

I have found 7 consecutive primes at higher s, could be more.

Offline

#7 2014-12-09 15:52:47

Stangerzv
Member
Registered: 2012-01-30
Posts: 266

Re: Max Number of Consecutive Primes

For Pr=34+3s

Prime-th{3036055, 3036056, 3036057, 3036058, 3036059, 3036060, 3036061}=s={50619193, 50619199, 50619221, 50619223, 50619229, 50619269, 50619271}
Pr={151857613, 151857631, 151857697, 151857703, 151857721, 151857841, 151857847} Consecutive Primes

Last edited by Stangerzv (2014-12-09 15:59:28)

Offline

#8 2014-12-09 15:54:32

Stangerzv
Member
Registered: 2012-01-30
Posts: 266

Re: Max Number of Consecutive Primes

I think there would be an infinite max numbers of consecutive primes as s goes to infinity.

Offline

#9 2014-12-12 01:32:59

Stangerzv
Member
Registered: 2012-01-30
Posts: 266

Re: Max Number of Consecutive Primes

The max number of consecutive primes for s<10,000,000 still 7.

Offline

#10 2014-12-13 23:14:52

Stangerzv
Member
Registered: 2012-01-30
Posts: 266

Re: Max Number of Consecutive Primes

Another Primes for For Pr=34+3s (7 consecutive)

Prime-th{10654019, 10654020, 10654021, 10654022, 10654023, 10654024, 10654025}=s={191885429, 191885471, 191885483, 191885509, 191885539, 191885543, 191885563}
Pr={575656321, 575656447, 575656483, 575656561, 575656651, 575656663, 575656723} Consecutive Primes

Offline

#11 2014-12-21 00:56:06

Stangerzv
Member
Registered: 2012-01-30
Posts: 266

Re: Max Number of Consecutive Primes

The max number of consecutive primes for Pr=34+3s is 8 (s<13,500,000)
For Pr=34+3s

Prime-th{13155307, 13155308, 13155309, 13155310, 13155311, 13155312, 13155313, 13155314}=s={239878543, 239878571, 239878579, 239878603, 239878621, 239878649, 239878663,
239878673}
Pr={719635663, 719635747, 719635771, 719635843, 719635897, 719635981, 719636023, 719636053} Consecutive Primes

Last edited by Stangerzv (2014-12-21 00:56:46)

Offline

#12 2014-12-27 01:41:06

Stangerzv
Member
Registered: 2012-01-30
Posts: 266

Re: Max Number of Consecutive Primes

No apparent result bigger than 8 consecutive primes for Prime-th up to 20,000,000 for Pr=34+3s

Offline

#13 2014-12-27 13:17:52

danaj
Member
Registered: 2014-03-03
Posts: 29

Re: Max Number of Consecutive Primes

length and p, where s = nth_prime(p) and 34+3s is prime; length the first run of consecutive p values

6 1373
7 1718020
8 13155307
9 62888993
10 247752179

For 82+5s:
6 131582
7 245075654
8 7358058514

Simple brute force walking primes looking at primality of 34+3s or 82+5s for s < 1e12.  No easy answers past these for this search method.

Offline

#14 2014-12-30 05:28:44

Stangerzv
Member
Registered: 2012-01-30
Posts: 266

Re: Max Number of Consecutive Primes

Just found another 8 consecutive prime for range 23,000,000<prime-th <24,000,000

Offline

#15 2014-12-30 08:57:58

danaj
Member
Registered: 2014-03-03
Posts: 29

Re: Max Number of Consecutive Primes

I can send you my perl script if you'd like.  It takes 15s to find three 8-consecutives for s < 1e9.  Searching to s < 1e10 takes about 2.5 minutes:

7 1718020 2492520 2671928 3036055 3562655 3594150 10654019 15191513 15626334 21063558 21752023 22152282 25059807 27161939 29545494 32921098 37188348 44503753 46206335 51087603 51960322 54481455 57923734 63665188 65256256 65443263 68573108 69790405 69888940 72402885 89135244 91447387 96231989 96907585 98870702 104486689 106724222 108468644 110963047 123035310 126428987 133783990 140775016 153601104 156826152 158202292 163519132 166930965 179742892 184518605 185994353 188583675 192392346 203631792 205873490 212190182 218841344 232714800 256292473 261209858 276867166 283985400 289567855 304492904 305351642 319820383 322860650 323803818 335518221 344398882 361505496 366930942 385324698 395261357 399795913 415012199 420673304 422144423 426839424 435086906 441592465 453986477
8 13155307 23373712 28619826 206480632 430788664 451840108
9 62888993
10 247752179

Searching to s < 1e11 (100,000,000,000) took 21 minutes:

7 1718020 2492520 2671928 3036055 3562655 3594150 10654019 15191513 15626334 21063558 21752023 22152282 25059807 27161939 29545494 32921098 37188348 44503753 46206335 51087603 51960322 54481455 57923734 63665188 65256256 65443263 68573108 69790405 69888940 72402885 89135244 91447387 96231989 96907585 98870702 104486689 106724222 108468644 110963047 123035310 126428987 133783990 140775016 153601104 156826152 158202292 163519132 166930965 179742892 184518605 185994353 188583675 192392346 203631792 205873490 212190182 218841344 232714800 256292473 261209858 276867166 283985400 289567855 304492904 305351642 319820383 322860650 323803818 335518221 344398882 361505496 366930942 385324698 395261357 399795913 415012199 420673304 422144423 426839424 435086906 441592465 453986477 466621403 466955611 470479122 475281381 478099131 486581146 488574100 492974241 495709419 503242169 514290308 524353559 526210953 547238431 555377530 560568673 563819394 564050336 565117578 567697430 574333477 581719259 604397264 605285517 609953548 611506702 619023097 627335360 644365306 664376162 665037413 686007851 718559335 725439993 735943665 743431923 746057515 748880752 750680263 794532893 797034046 807908141 817185739 830061428 838793990 844170390 847996148 863088773 868761819 872583472 875894406 880427154 885068607 885730110 886707614 897000052 922799091 930122687 949561295 953536846 965574106 970670184 971616015 984136807 999904292 1032348520 1032626596 1038415609 1042590507 1063551577 1071083510 1084818946 1092401906 1092937465 1095569057 1097103079 1121692213 1127021960 1141442850 1142159307 1167453552 1179332930 1198709921 1207536623 1225783001 1226020529 1226973918 1230881242 1255337127 1266567073 1269833145 1288913145 1301900559 1315347414 1330558720 1335151552 1336167535 1336470638 1357529972 1366303467 1367532201 1394632344 1415994612 1425615667 1468126216 1479052712 1484197484 1484664232 1499162590 1510892825 1525540560 1538768858 1541431708 1547113639 1561569771 1573285197 1575338467 1608245600 1620892699 1636594726 1639912926 1642785097 1649448543 1658387196 1659492894 1669878049 1673030859 1680288649 1689009936 1705139805 1707877965 1720548461 1725560049 1727975655 1740450178 1757696409 1767977017 1774252457 1783722479 1833272684 1835641302 1864180009 1875220655 1894374764 1914950297 1925191608 1930188541 1944046812 1947734807 1950943878 1961537003 1968415550 1978950200 1983147463 1992503523 2003383667 2011759321 2036328796 2074864705 2083105576 2097268421 2120562842 2131335524 2173046960 2174549806 2197537096 2206149990 2239254808 2243414356 2349463495 2368648878 2388262838 2397241591 2398126033 2403896576 2417795626 2421180508 2427214723 2433644912 2460192669 2464829434 2466386056 2470597216 2473662702 2477156833 2481924935 2486632950 2535173281 2562687057 2577546536 2594427982 2602427582 2615924025 2627636732 2648467667 2681906133 2708967552 2721761110 2741304277 2746549938 2750335395 2753208097 2763210973 2766258139 2777676867 2787956664 2817979773 2820157908 2837602399 2869185904 2878113684 2882066301 2884645265 2912256157 2935732944 2939577836 2946296457 2955639898 2961631157 2989076982 2996581210 3004860881 3019444513 3024664264 3026879459 3092518506 3094303338 3099197655 3127207507 3128262874 3140049442 3157014173 3175544783 3193904988 3194803790 3202819376 3217890148 3225417795 3229520764 3232636927 3244256924 3258840570 3277320913 3278576127 3285898935 3296994608 3312205351 3332431095 3342688030 3367721960 3380264281 3384164887 3396537088 3402359710 3403327218 3406882404 3419374349 3453540047 3473030524 3478573403 3487003920 3489342936 3541544528 3553821171 3563989241 3570263926 3579929644 3600057302 3606082748 3608868228 3612932294 3628577024 3631111020 3639429262 3648181186 3664377198 3676997253 3694484527 3733723540 3750029130 3770734294 3792743589 3807294468 3809322646 3818970943 3826632839 3852382997 3864241176 3937518769 3964472367 3968680328 3978909813 3980535308 3989589875 4032468634 4043649533 4045499779 4059220413 4091714016 4092344452 4097893987 4103216975 4104895899
8 13155307 23373712 28619826 206480632 430788664 451840108 723650223 778689176 922591383 943068103 1005001898 1083424548 1406260752 1528839396 1653992654 1884407047 2112863733 2420339382 2444147088 2467436354 2559176982 3141752981 3239363657 3314161732 3346438597 3510021953
9 62888993 2337819127 2805299994 3543590679 3649181083
10 247752179

Here is a Pari/GP version.  It runs slower than Perl's ntheory for this, but it's not too bad (it needs Pari 2.8):

s=0;sr=0;cr=0;forprime(p=1,1e9,s++;if(isprime(34+3*p),cr++,if(cr-sr>=7,print(cr-sr," ",sr));cr=s+1;sr=s+1))

Offline

#16 2014-12-30 12:43:17

Stangerzv
Member
Registered: 2012-01-30
Posts: 266

Re: Max Number of Consecutive Primes

Dear Danaj can you list down the primes of 8 consecutive from your calculation? I am using mathematica and it is a bit slow. Mathematica got primality algorithm to verify the numbers, perhaps that makes it so slow. Anyway, thanks for the script, I am looking for a longer prime consecutive with the inputs.

Offline

#17 2014-12-30 13:42:05

danaj
Member
Registered: 2014-03-03
Posts: 29

Re: Max Number of Consecutive Primes

This takes the 'p' values and computes the 8 's' values corresponding to prime[p+0], prime[p+1], ..., prime[p+7].  Of course the 's' values are prime and sequential, but we can also check that for each one, 34+3*s is also prime.  I will note that the 34+3s results are not sequential primes -- it's hard to tell if this is expected in the original post, but your posted results don't have them sequential.

These are just the values for 8.  The runs of 9 and 10 would also be runs of 8.

I'm surprised Mathematica isn't faster.  It uses a BPSW+1MR for large inputs, and may drop the extra MR for these small numbers where BPSW is deterministic.  That would match Pari and Perl/ntheory.  The forprime() call does help since we can easily loop through the primes.

for my $s (qw/13155307 23373712 28619826 206480632 430788664 451840108 723650223 778689176 922591383 943068103 1005001898 1083424548 1406260752 1528839396 1653992654 1884407047 2112863733 2420339382 2444147088 2467436354 2559176982 3141752981 3239363657 3314161732 3346438597 3510021953/) { say "$p: ", join(" ",map { nth_prime($p+$_) } 0..7); }'
13155307: 239878543 239878571 239878579 239878603 239878621 239878649 239878663 239878673
23373712: 440460583 440460589 440460593 440460619 440460623 440460659 440460673 440460703
28619826: 545465579 545465593 545465633 545465659 545465731 545465743 545465749 545465759
206480632: 4365959711 4365959713 4365959753 4365959779 4365959789 4365959809 4365959879 4365959909
430788664: 9442018519 9442018559 9442018583 9442018589 9442018601 9442018609 9442018613 9442018643
451840108: 9926055071 9926055079 9926055131 9926055133 9926055143 9926055163 9926055169 9926055173
723650223: 16255022843 16255022851 16255022863 16255022869 16255022939 16255022941 16255022969 16255023019
778689176: 17551241549 17551241551 17551241563 17551241579 17551241581 17551241593 17551241611 17551241639
922591383: 20958804241 20958804271 20958804283 20958804323 20958804341 20958804343 20958804371 20958804413
943068103: 21445686761 21445686781 21445686791 21445686793 21445686811 21445686839 21445686851 21445686901
1005001898: 22921075381 22921075409 22921075421 22921075423 22921075433 22921075451 22921075493 22921075501
1083424548: 24795040741 24795040759 24795040801 24795040903 24795040931 24795040943 24795040951 24795040969
1406260752: 32567701541 32567701561 32567701571 32567701609 32567701631 32567701643 32567701693 32567701709
1528839396: 35540355871 35540355881 35540355889 35540355901 35540355911 35540355923 35540355953 35540355959
1653992654: 38585987383 38585987399 38585987413 38585987441 38585987509 38585987519 38585987549 38585987591
1884407047: 44218726703 44218726723 44218726763 44218726793 44218726813 44218726829 44218726859 44218726913
2112863733: 49832772751 49832772763 49832772791 49832772793 49832772811 49832772851 49832772943 49832772961
2420339382: 57428667449 57428667473 57428667509 57428667529 57428667613 57428667671 57428667701 57428667799
2444147088: 58018595399 58018595419 58018595431 58018595443 58018595461 58018595483 58018595501 58018595519
2467436354: 58595995259 58595995273 58595995279 58595995319 58595995331 58595995349 58595995363 58595995439
2559176982: 60872272801 60872272819 60872272829 60872272859 60872272889 60872272913 60872272931 60872272933
3141752981: 75403452713 75403452721 75403452749 75403452781 75403452799 75403452811 75403452833 75403452881
3239363657: 77849739503 77849739521 77849739529 77849739589 77849739619 77849739659 77849739673 77849739719
3314161732: 79726451263 79726451293 79726451303 79726451353 79726451393 79726451443 79726451459 79726451503
3346438597: 80536791493 80536791509 80536791521 80536791553 80536791583 80536791611 80536791623 80536791659
3510021953: 84648776909 84648776911 84648776921 84648776939 84648776941 84648776963 84648776999 84648777019

Offline

#18 2014-12-30 17:48:07

Stangerzv
Member
Registered: 2012-01-30
Posts: 266

Re: Max Number of Consecutive Primes

Thanks danaj..the idea is to get all the Pr as prime with the sequential prime-th (i.e. s). Mathematica uses PrimeQ, a good primality algorithm for small primes, for larger prime you can use provableprimeQ which verifies the number to be prime. This is why it takes so long and if your computer is slow it could take months. I am trying to get longer series, perhaps up to 40 consecutive primes. So far, 8 is the largest.

Offline

#19 2014-12-30 19:08:33

danaj
Member
Registered: 2014-03-03
Posts: 29

Re: Max Number of Consecutive Primes

PrimeQ uses, from the best documentation I know of, BPSW + a base 3 strong probable prime test.  BPSW is deterministic for 64-bit numbers like we're using, much less adding another M-R test.  There should be no reason to use ProvablePrimeQ here.  Or another way of looking at it: use PrimeQ, then for the few found examples, use ProvablePrimeQ -- if something comes up false then you have a great example of Mathematica doing something wrong.

Pari/GP has isprime() (like I put in the example) which is deterministic (BPSW then APR-CL if large), or ispseudoprime for just BPSW.  They're identical for 64-bit inputs.  Perl/ntheory has is_provable_prime() to do a proof, but similarly it is identical to is_prime or is_prob_prime for 64-bit inputs.

"So far, 8 is the largest."  There is an example of 10, but I did not find anything higher than that.

Offline

#20 2014-12-31 12:41:31

Stangerzv
Member
Registered: 2012-01-30
Posts: 266

Re: Max Number of Consecutive Primes

Thanks danaj for the input. Can you list the 10 consecutive primes. Thanks again for the script.

Offline

#21 2014-12-31 17:23:38

danaj
Member
Registered: 2014-03-03
Posts: 29

Re: Max Number of Consecutive Primes

Stangerzv wrote:

Thanks danaj for the input. Can you list the 10 consecutive primes.

It's in post 15: p=247752179

247752179: 5286145759 5286145811 5286145829 5286145831 5286145841 5286145873 5286145951 5286145981 5286145999 5286146029

You can do this with Mathematica like:

Table[Prime[247752179+i-1],{i,10}]

or Perl/ntheory as:

perl -Mntheory=:all -E 'say nth_prime(247752179+$_) for 0..9;'

or Pari/GP (slow) as:

for(i=0,9,print(prime(247752179+i)))

or the faster but still much slower than the others Pari/GP:

s=prime(247752179); for(i=0,9,print(s);s=nextprime(s+1))

Offline

#22 2015-01-23 11:38:04

Stangerzv
Member
Registered: 2012-01-30
Posts: 266

Re: Max Number of Consecutive Primes

Dear danaj, is it possible to run a program that you wrote using gpu processors with thousands of core doing the calculation? I am upgrading my computing power to mini-supercomputer using nvidia processors. It would be a great thing to find any series of in tens or perhaps near hundreds long series. If they don't exist then we can conjecture there would be no series longer than max number found so far.

Last edited by Stangerzv (2015-01-23 11:38:44)

Offline

Board footer

Powered by FluxBB