This README goes with fastprimes5.cc ==================================== ____ offset relative to previous candidate. | _ candidates (non-primes are put between parenthesis). | | v v +0 1 ----┼--- p_ =|1¹(0) | { +1 } +1 +1 +1 +1 +1 +1 ... a series of ones, repeated. | 1 2 3 4 5 6 7 8 ... all integers, starting at 1² | ^ ^------------. window2_:{start_:1², head_:1, last_:2}, window1_:{start_:1¹, head_:1, last_:1²} | ↓ { +1 } +1 +1 +1 +1 +1 +1 ... the differences between: v 1¹ = 1¹ 2 3 4 5 6 7 8 ... all integers, starting at 1¹ 1 | <-- last_candidate_ +1 2 | .------------------------ expected_failure_:2 +1 3 | | +1 (4) = 2² | | <-- next_prime_squared_:4 ----┼--- | v p_ =|2¹(1) `--------> 2 3 4 5 6 7 8 ... all integers, starting at 1¹ | 2 2 2 2 2 2 2 ... expected_failure_ never matches and therefore never changes | 4 5 6 7 8 9 10 11 ... all integers, starting at 2² <------. | { +1 } +1 +1 +1 +1 +1 +1 ... the differences between: | | 4 5 6 7 8 9 10 11 ... the ones left after removing the 'multiplied by 1¹' from .' | ↑ ^------------. window2_:{start_:2², head_:4, last_:5}, window1_:{start_:2¹, head_:2, last_:2²} | ↓ { +1 } +1 +1 +1 +1 +1 +1 ... the differences between: v 2¹ = 2¹ 3 4 5 6 7 8 9 ... all integers, starting at 2¹ 4 | <-- last_candidate_:4 +1 5 | +1 (6) = 2¹ * 3 <-- expected_failure_:6 +1 7 | +1 (8) = 2¹ * 4 <-- expected_failure_:8 +1 (9) = 3² | <-- next_prime_squared_:9 ----┼--- | p_ =|3¹(2) `--------> 5 6 7 8 ... all integers, starting at 2¹ | 10 12 14 16 ... multiplied by 2¹ (this is what expected_failure_ runs over), remove these from: | 9 10 11 12 13 14 15 16 ... all integers, starting at 3² | { +2 } +2 +2 ... the differences between: | 9 11 13 15 ... the ones left after skipping expected_failure_'s. | ↑ ^----------. window2_:{start_:3², head_:9, last_:11} window1_:{start_:3¹, head_:3, last_:3²} | ↓ { +2 } +2 +2 +2 +2 +2 +2 ... the differences between: v 3¹ = 3¹ 5 7 9 11 13 15 17 ... all integers not divisible by primes less than 3¹ 9 | <-- last_candidate_:9 +2 11 | +2 13 | +2 (15) = 3¹ * 5 <-- expected_failure_:15 +2 17 | +2 19 | +2 (21) = 3¹ * 7 <-- expected_failure_:21 +2 23 | +2 (25) = 5² | <-- next_prime_squared_:25 ----┼---- | p_ =|5¹(3) `-------> 9 11 13 ... all integers not divisible by primes less than 3¹ | 27 33 39 ... multiplied by 3¹ (this is what expected_failure_ runs over), remove these from: | 25 27 29 31 33 35 37 39 ... all integers, starting at 5², not divisible by primes less than 3¹ | { +4 +2 } +4 +2 ... the differences between: | 25 29 31 35 37 ... the ones left after skipping expected_failure_'s. | ↑ ^-----------. window2_:{start_:5², head_:25, last_:29} window1_:{start_:5¹, head_:5, last_:5²} | ↓ { +2 +4 } +2 +4 +2 +4 +2 ... the differences between: v 5¹ = 5¹ 7 11 13 17 19 23 25 ... all integers not divisible by primes less than 5¹ 25 | <-- last_candidate_:25 +4 29 | +2 31 | +4 (35) = 5¹ * 7 <-- expected_failure_:35 +2 37 | +4 41 | +2 43 | +4 47 | +2 (49) = 7^2 | <-- next_prime_squared_:49 ----┼---- | p_ =|7¹(4) `---------> 11 13 17 19 23 25 ... all integers not divisible by primes less than 5¹ | 55 65 85 95 115 125 ... multiplied by 5¹ (this is what expected_failure_ runs over), remove these from: | 49 53 55 59 61 65 67 71 73 77 79 83 85 89 91 95 97 101 103 107 109 113 115 119 121 125 127 ... all integers, starting at 7², not divisible by primes less than 5¹ | { +4 +6 +2 +6 +4 +2 +4 +2 } +4 +6 +2 +6 +4 +2 +4 +2 +4 +6 +2 +6 ... the differences between: | 49 53 59 61 67 71 73 77 79 83 89 91 97 101 103 107 109 113 119 121 127 ... the ones left after skipping expected_failure_'s. | ↑ ^--------------. window2_:{start_:7², head_:49, last_:53} window1_:{start_:7¹, head_:7, last_:7²} | ↓ { +4 +2 +4 +2 +4 +6 +2 +6 } +4 +2 +4 +2 ... the differences between: v 7¹ = 7¹ 11 13 17 19 23 29 31 37 41 43 47 49 ... all integers not divisible by primes less than 7¹ 49 | <-- last_candidate_:49 +4 53 | +6 59 | +2 61 | +6 67 | +4 71 | +2 73 | +4 (77) = 7 * 11 <-- expected_failure_:77 +2 79 | +4 83 | +6 89 | +2 (91) = 7 * 13 <-- expected_failure_:91 +6 97 | +4 101 | +2 103 | +4 107 | +2 109 | +4 113 | +6 (119) = 7 * 17 <-- expected_failure_:119 +2 (121) = 11^2 | <-- next_prime_squared_:121 ----┼---- | p_ =|11¹(5) `--------------> 19 23 29 31 ... all integers not divisible by primes less than 7¹ | 133 161 203 217 ... multiplied by 7¹ (this is what expected_failure_ runs over), remove these from: | 121 127 131 133 137 139 143 149 151 157 161 163 167 169 173 179 181 187 191 193 197 199 203 209 211 217 221 ... | 6 4 2+ 4 2 4 6 2 6 4+ 2 4 2 4 6 2 6 4 2 4 2 4+ 6 2 6+ 4 ... v { +6 +4 +6 +2 +4 +6 +2 +6 +6 +4 +2 +4 +6 +2 +6 +4 +2 +4 +2 +10 +2 +10 ... 121 +6 127 +4 131 +6 137 +2 139 +4 (143) = 11 * 13 +6 149 | +2 151 | +6 157 | +6 163 | +4 167 | +2 (169) = 13^2 | | `--------+4-------> 17 -------+2------> 19 ----+4---> 23 -----+6-----> 29 -+2-> 31 ... (not div by 2,3,5,7) +4 173 ---------------> 173 179 181 187 191 193 197 199 209 211 221 ... 4 6 2 6+ 4 2 4 2 10+ 2 10 ... -------- { +4 +6 + 2 +10 +2 +4 +2 +12 +10 +2 +4 +2 +4 +6 +2 +6 +4 +6 +6 +6 +2 +6 +4 +2 +6 ... +4 173 +6 179 +2 181 +10 191 +2 193 +4 197 +2 199 +12 211 +10 (221) = 13 * 17 +2 223 +4 227 +2 229 +4 233 +6 239 +2 241 +6 (247) = 13 * 19 +4 251 +6 257 +6 263 +6 269 +2 271 +6 277 +4 281 +2 283 +6 (289) = 17^2 -------- +4 293 +14 307 +4 311 +2 313 +4 317 +6 (323) = 17 * 19 +8 331 +6 337 +10 347 +2 349 +4 353 +6 359 +2 (361) = 19^2 -------- +6 367 +6 373 +6 379 +4 383 +6 389 +8 397 +4 401 +8 409 +10 419 +2 421 +10 431 +2 433 +4 (437) = 19 * 23 +2 439 +4 443 +6 449 +8 457 +4 461 +2 463 +4 467 +12 479 +8 487 +4 491 +8 499 +4 503 +6 509 +12 521 +2 523 +6 (529) = 23^2 -------- +12 541 +6 547 +10 557 +6 563 +6 569 +2 571 +6 577 +10 587 +6 593 +6 599 +2 601 +6 607 +6 613 +4 617 +2 619 +12 631 +10 641 +2 643 +4 647 +6 653 +6 659 +2 661 +6 (667) = 23 * 29 +6 673 +4 677 +6 683 +8 691 +10 701 +8 709 +4 (713) = 23 * 31 +6 719 +8 727 +6 733 +6 739 +4 743 +8 751 +6 757 +4 761 +8 769 +4 773 +14 787 +10 797 +12 809 +2 811 +10 821 +2 823 +4 827 +2 829 +10 839 +2 (841) = 29^2 -------- +12 853 +4 857 +2 859 +4 863 +14 877 +4 881 +2 883 +4 887 +12 (899) = 29 * 31 +8 907 +4 911 +8 919 +10 929 +8 937 +4 941 +6 947 +6 953 +8 (961) = 31^2 -------- +6 967 +4 971 +6 977 +6 983 +8 991 +6 997 +12 1009 +4 1013 +6 1019 +2 1021 +10 1031 +2 1033 +6 1039 +10 1049 +2 1051 +10 1061 +2 1063 +6 1069 +18 1087 +4 1091 +2 1093 +4 1097 +6 1103 +6 1109 +8 1117 +6 1123 +6 1129 +18 (1147) = 31 * 37 +4 1151 +2 1153 +10 1163 +8 1171 +10 1181 +6 1187 +6 1193 +8 1201 +12 1213 +4 1217 +6 1223 +6 1229 +2 1231 +6 1237 +12 1249 +10 1259 +12 (1271) = 31 * 41 +6 1277 +2 1279 +4 1283 +6 1289 +2 1291 +6 1297 +4 1301 +2 1303 +4 1307 +12 1319 +2 1321 +6 1327 +6 (1333) = 31 * 43 +28 1361 +6 1367 +2 (1369) = 37^2 -------- +4 1373 +8 1381 +18 1399 +10 1409 +14 1423 +4 1427 +2 1429 +4 1433 +6 1439 +8 1447 +4 1451 +2 1453 +6 1459 +12 1471 +10 1481 +2 1483 +4 1487 +2 1489 +4 1493 +6 1499 +12 1511 +6 (1517) = 37 * 41 +6 1523 +8 1531 +12 1543 +6 1549 +4 1553 +6 1559 +8 1567 +4 1571 +8 1579 +4 1583 +8 (1591) = 37 * 43 +6 1597 +4 1601 +6 1607 +2 1609 +4 1613 +6 1619 +2 1621 +6 1627 +10 1637 +20 1657 +6 1663 +4 1667 +2 1669 +12 (1681) = 41^2 -------- +12 1693 +4 1697 +2 1699 +10 1709 +12 1721 +2 1723 +10 1733 +8 1741 +6 1747 +6 1753 +6 1759 +4 (1763) = 41 * 43 +14 1777 +6 1783 +4 1787 +2 1789 +12 1801 +10 1811 +12 1823 +8 1831 +16 1847 +2 (1849) = 43^2 -------- +12 1861 +6 1867 +4 1871 +2 1873 +4 1877 +2 1879 +10 1889 +12 1901 +6 1907 +6 1913 +18 1931 +2 1933 +16 1949 +2 1951 +22 1973 +6 1979 +8 1987 +6 1993 +4 1997 +2 1999 +4 2003 +8 2011 +6 2017 +4 (2021) = 43 * 47 +6 2027 +2 2029 +10 2039 +14 2053 +10 2063 +6 2069 +12 2081 +2 2083 +4 2087 +2 2089 +10 2099 +12 2111 +2 2113 +16 2129 +2 2131 +6 2137 +4 2141 +2 2143 +10 2153 +8 2161 +18 2179 +24 2203 +4 2207 +2 (2209) = 47^2 -------- +4 2213 +8 2221 +16 2237 +2 2239 +4 2243 +8 2251 +16 2267 +2 2269 +4 2273 +8 2281 +6 2287 +6 2293 +4 2297 +12 2309 +2 2311 +22 2333 +6 2339 +2 2341 +6 2347 +4 2351 +6 2357 +14 2371 +6 2377 +4 2381 +2 2383 +6 2389 +4 2393 +6 2399 +12 2411 +6 2417 +6 2423 +14 2437 +4 2441 +6 2447 +12 2459 +8 2467 +6 2473 +4 2477 +14 (2491) = 47 * 53 +12 2503 +18 2521 +10 2531 +8 2539 +4 2543 +6 2549 +2 2551 +6 2557 +22 2579 +12 2591 +2 2593 +16 2609 +8 2617 +4 2621 +12 2633 +14 2647 +10 2657 +2 2659 +4 2663 +8 2671 +6 2677 +6 2683 +4 2687 +2 2689 +4 2693 +6 2699 +8 2707 +4 2711 +2 2713 +6 2719 +10 2729 +2 2731 +10 2741 +8 2749 +4 2753 +14 2767 +6 (2773) = 47 * 59 +4 2777 +12 2789 +2 2791 +6 2797 +4 2801 +2 2803 +6 (2809) = 53^2 -------- +10 2819 +14 2833 +4 2837 +6 2843 +8 2851 +6 2857 +4 2861 +18 2879 +8 2887 +10 2897 +6 2903 +6 2909 +8 2917 +10 2927 +12 2939 +14 2953 +4 2957 +6 2963 +6 2969 +2 2971 +28 2999 +2 3001 +10 3011 +8 3019 +4 3023 +14 3037 +4 3041 +8 3049 +12 3061 +6 3067 +12 3079 +4 3083 +6 3089 +20 3109 +10 3119 +2 3121 +6 (3127) = 53 * 59 +10 3137 +26 3163 +4 3167 +2 3169 +12 3181 +6 3187 +4 3191 +12 3203 +6 3209 +8 3217 +4 3221 +8 3229 +4 (3233) = 53 * 61 +18 3251 +2 3253 +4 3257 +2 3259 +12 3271 +28 3299 +2 3301 +6 3307 +6 3313 +6 3319 +4 3323 +6 3329 +2 3331 +12 3343 +4 3347 +12 3359 +2 3361 +10 3371 +2 3373 +16 3389 +2 3391 +16 3407 +6 3413 +20 3433 +16 3449 +8 3457 +4 3461 +2 3463 +4 3467 +2 3469 +12 (3481) = 59^2 -------- +10 3491 +8 3499 +12 3511 +6 3517 +10 3527 +2 3529 +4 3533 +6 3539 +2 3541 +6 3547 +10 3557 +2 3559 +12 3571 +10 3581 +2 3583 +10 3593 +6 (3599) = 59 * 61 +8 3607 +6 3613 +4 3617 +6 3623 +8 3631 +6 3637 +6 3643 +16 3659 +12 3671 +2 3673 +4 3677 +14 3691 +6 3697 +4 3701 +8 3709 +10 3719 +2 (3721) = 61^2 -------- +6 3727 +6 3733 +6 3739 +22 3761 +6 3767 +2 3769 +10 3779 +14 3793 +4 3797 +6 3803 +18 3821 +2 3823 +10 3833 +14 3847 +4 3851 +2 3853 +10 3863 +14 3877 +4 3881 +8 3889 +18 3907 +4 3911 +6 3917 +2 3919 +4 3923 +6 3929 +2 3931 +12 3943 +4 3947 +20 3967 +22 3989 +12 4001 +2 4003 +4 4007 +6 4013 +6 4019 +2 4021 +6 4027 +22 4049 +2 4051 +6 4057 +16 4073 +6 4079 +8 (4087) = 61 * 67 +4 4091 +2 4093 +6 4099 +12 4111 +16 4127 +2 4129 +4 4133 +6 4139 +14 4153 +4 4157 +2 4159 +18 4177 +24 4201 +10 4211 +6 4217 +2 4219 +10 4229 +2 4231 +10 4241 +2 4243 +10 4253 +6 4259 +2 4261 +10 4271 +2 4273 +10 4283 +6 4289 +8 4297 +30 4327 +4 (4331) = 61 * 71 +6 4337 +2 4339 +10 4349 +8 4357 +6 4363 +10 4373 +18 4391 +6 4397 +12 4409 +12 4421 +2 4423 +18 4441 +6 4447 +4 4451 +2 (4453) = 61 * 73 +4 4457 +6 4463 +18 4481 +2 4483 +6 (4489) = 67^2 -------- +4 4493 +14 4507 +6 4513 +4 4517 +2 4519 +4 4523 +24 4547 +2 4549 +12 4561 +6 4567 +16 4583 +8 4591 +6 4597 +6 4603 +18 4621 +16 4637 +2 4639 +4 4643 +6 4649 +2 4651 +6 4657 +6 4663 +10 4673 +6 4679 +12 4691 +12 4703 +18 4721 +2 4723 +6 4729 +4 4733 +18 4751 +6 (4757) = 67 * 71 +2 4759 +24 4783 +4 4787 +2 4789 +4 4793 +6 4799 +2 4801 +12 4813 +4 4817 +14 4831 +30 4861 +10 4871 +6 4877 +12 4889 +2 (4891) = 67 * 73 +12 4903 +6 4909 +10 4919 +12 4931 +2 4933 +4 4937 +6 4943 +8 4951 +6 4957 +10 4967 +2 4969 +4 4973 +14 4987 +6 4993 +6 4999 +4 5003 +6 5009 +2 5011 +10 5021 +2 5023 +16 5039 +2 (5041) = 71^2 -------- +10 5051 +8 5059 +18 5077 +4 5081 +6 5087 +12 5099 +2 5101 +6 5107 +6 5113 +6 5119 +28 5147 +6 5153 +14 5167 +4 5171 +8 5179 +4 (5183) = 71 * 73 +6 5189 +8 5197 +12 5209 +18 5227 +4 5231 +2 5233 +4 5237 +24 5261 +12 5273 +6 5279 +2 5281 +16 5297 +6 5303 +6 5309 +14 5323 +6 (5329) = 73^2 -------- +4 5333 +14 5347 +4 5351 +30 5381 +6 5387 +6 5393 +6 5399 +8 5407 +6 5413 +4 5417 +2 5419 +12 5431 +6 5437 +4 5441 +2 5443 +6 5449 +22 5471 +6 5477 +2 5479 +4 5483 +18 5501 +2 5503 +4 5507 +12 5519 +2 5521 +6 5527 +4 5531 +26 5557 +6 5563 +6 5569 +4 5573 +8 5581 +10 5591 +32 5623 +16 5639 +2 5641 +6 5647 +4 5651 +2 5653 +4 5657 +2 5659 +10 5669 +14 5683 +6 5689 +4 5693 +8 5701 +10 5711 +6 5717 +20 5737 +4 5741 +2 5743 +6 5749 +18 (5767) = 73 * 79 +12 5779 +4 5783 +8 5791 +10 5801 +6 5807 +6 5813 +8 5821 +6 5827 +12 5839 +4 5843 +6 5849 +2 5851 +6 5857 +4 5861 +6 5867 +2 5869 +10 5879 +2 5881 +16 5897 +6 5903 +20 5923 +4 5927 +12 5939 +14 5953 +28 5981 +6 5987 +20 6007 +4 6011 +18 6029 +8 6037 +6 6043 +4 6047 +6 6053 +6 (6059) = 73 * 83 +8 6067 +6 6073 +6 6079 +10 6089 +2 6091 +10 6101 +12 6113 +8 6121 +10 6131 +2 6133 +10 6143 +8 6151 +12 6163 +10 6173 +24 6197 +2 6199 +4 6203 +8 6211 +6 6217 +4 6221 +8 6229 +12 (6241) = 79^2 -------- +6 6247 +10 6257 +6 6263 +6 6269 +2 6271 +6 6277 +10 6287 +12 6299 +2 6301 +10 6311 +6 6317 +6 6323 +6 6329 +8 6337 +6 6343 +10 6353 +6 6359 +2 6361 +6 6367 +6 6373 +6 6379 +10 6389 +8 6397 +24 6421 +6 6427 +22 6449 +2 6451 +18 6469 +4 6473 +8 6481 +10 6491 +30 6521 +8 6529 +18 6547 +4 6551 +2 6553 +4 (6557) = 79 * 83 +6 6563 +6 6569 +2 6571 +6 6577 +4 6581 +18 6599 +8 6607 +12 6619 +18 6637 +16 6653 +6 6659 +2 6661 +12 6673 +6 6679 +10 6689 +2 6691 +10 6701 +2 6703 +6 6709 +10 6719 +14 6733 +4 6737 +24 6761 +2 6763 +16 6779 +2 6781 +10 6791 +2 6793 +10 6803 +20 6823 +4 6827 +2 6829 +4 6833 +8 6841 +16 6857 +6 6863 +6 6869 +2 6871 +12 6883 +6 (6889) = 83^2 -------- +10 6899 +8 6907 +4 6911 +6 6917 +30 6947 +2 6949 +10 6959 +2 6961 +6 6967 +4 6971 +6 6977 +6 6983 +8 6991 +6 6997 +4 7001 +12 7013 +6 7019 +8 7027 +12 7039 +4 7043 +14 7057 +12 7069 +10 7079 +24 7103 +6 7109 +12 7121 +6 7127 +2 7129 +22 7151 +8 7159 +18 7177 +10 7187 +6 7193 +14 7207 +4 7211 +2 7213 +6 7219 +10 7229 +8 7237 +6 7243 +4 7247 +6 7253 +30 7283 +14 7297 +10 7307 +2 7309 +12 7321 +10 7331 +2 7333 +16 7349 +2 7351 +18 7369 +18 (7387) = 83 * 89 +6 7393 +18 7411 +6 7417 +16 7433 +18 7451 +6 7457 +2 7459 +18 7477 +4 7481 +6 7487 +2 7489 +10 7499 +8 7507 +10 7517 +6 7523 +6 7529 +8 7537 +4 7541 +6 7547 +2 7549 +10 7559 +2 7561 +12 7573 +4 7577 +6 7583 +6 7589 +2 7591 +12 7603 +4 7607 +14 7621 +18 7639 +4 7643 +6 7649 +20 7669 +4 7673 +8 7681 +6 7687 +4 7691 +8 7699 +4 7703 +14 7717 +6 7723 +4 7727 +14 7741 +12 7753 +4 7757 +2 7759 +30 7789 +4 7793 +24 7817 +6 7823 +6 7829 +12 7841 +12 7853 +14 7867 +6 7873 +4 7877 +2 7879 +4 7883 +18 7901 +6 7907 +12 7919 +2 (7921) = 89^2 -------- The 1000-th prime is 7919