Primes: n*2^m+1: Difference between revisions
Content added Content deleted
Thundergnat (talk | contribs) m (clarify slightly) |
Thundergnat (talk | contribs) m (oops. correct range.) |
||
Line 1: | Line 1: | ||
;Task |
;Task |
||
* Find and display the first 45 ('''n''') primes of the form '''n × 2<sup>m</sup> + 1''' where '''m''' is the smallest valid |
* Find and display the first 45 ('''n''') primes of the form '''n × 2<sup>m</sup> + 1''' where '''m''' is the smallest valid non-negative integer. |
||
;Stretch |
;Stretch |
||
* Find and display the first 50 ('''n''') primes of the form '''n × 2<sup>m</sup> + 1''' where '''m''' is the smallest valid |
* Find and display the first 50 ('''n''') primes of the form '''n × 2<sup>m</sup> + 1''' where '''m''' is the smallest valid non-negative integer. |
||
;Stretch harder |
;Stretch harder |
||
* Find and display the first 400 ('''n''') primes of the form '''n × 2<sup>m</sup> + 1''' where '''m''' is the smallest valid |
* Find and display the first 400 ('''n''') primes of the form '''n × 2<sup>m</sup> + 1''' where '''m''' is the smallest valid non-negative integer. |
||
Revision as of 23:41, 23 September 2022
- Task
- Find and display the first 45 (n) primes of the form n × 2m + 1 where m is the smallest valid non-negative integer.
- Stretch
- Find and display the first 50 (n) primes of the form n × 2m + 1 where m is the smallest valid non-negative integer.
- Stretch harder
- Find and display the first 400 (n) primes of the form n × 2m + 1 where m is the smallest valid non-negative integer.
- See also
A050921 - Smallest prime of form n*2^m+1
Raku
First 382 in less than a second. 383 pushes the total accumulated time over 25 seconds.
-> $n { (^∞).map: -> $m { if (my $p = $n × 2 ** $m + 1).is-prime { say "$n: $p"; last } } } for 1..400
- Output:
1: 2 2: 3 3: 7 4: 5 5: 11 6: 7 7: 29 8: 17 9: 19 10: 11 11: 23 12: 13 13: 53 14: 29 15: 31 16: 17 17: 137 18: 19 19: 1217 20: 41 21: 43 22: 23 23: 47 24: 97 25: 101 26: 53 27: 109 28: 29 29: 59 30: 31 31: 7937 32: 257 33: 67 34: 137 35: 71 36: 37 37: 149 38: 1217 39: 79 40: 41 41: 83 42: 43 43: 173 44: 89 45: 181 46: 47 47: 1487939695262196876907983166454197495251350196192890428923003345454869706240895712896623468784438158657419591298913094265537812046389415279164757669092989298186306341246574002177 48: 97 49: 197 50: 101 51: 103 52: 53 53: 107 54: 109 55: 881 56: 113 57: 229 58: 59 59: 1889 60: 61 61: 977 62: 7937 63: 127 64: 257 65: 131 66: 67 67: 269 68: 137 69: 139 70: 71 71: 569 72: 73 73: 293 74: 149 75: 151 76: 1217 77: 617 78: 79 79: 317 80: 641 81: 163 82: 83 83: 167 84: 337 85: 1361 86: 173 87: 349 88: 89 89: 179 90: 181 91: 23297 92: 11777 93: 373 94: 1487939695262196876907983166454197495251350196192890428923003345454869706240895712896623468784438158657419591298913094265537812046389415279164757669092989298186306341246574002177 95: 191 96: 97 97: 389 98: 197 99: 199 100: 101 101: 809 102: 103 103: 6750209 104: 3329 105: 211 106: 107 107: 857 108: 109 109: 6977 110: 881 111: 223 112: 113 113: 227 114: 229 115: 461 116: 233 117: 937 118: 1889 119: 239 120: 241 121: 30977 122: 977 123: 7873 124: 7937 125: 251 126: 127 127: 509 128: 257 129: 1033 130: 131 131: 263 132: 2113 133: 2129 134: 269 135: 271 136: 137 137: 1097 138: 139 139: 557 140: 281 141: 283 142: 569 143: 1288029493427961857 144: 577 145: 9281 146: 293 147: 37633 148: 149 149: 1193 150: 151 151: 2417 152: 1217 153: 307 154: 617 155: 311 156: 157 157: 40193 158: 317 159: 10177 160: 641 161: 1289 162: 163 163: 653 164: 83969 165: 331 166: 167 167: 21377 168: 337 169: 677 170: 1361 171: 43777 172: 173 173: 347 174: 349 175: 701 176: 353 177: 709 178: 179 179: 359 180: 181 181: 2897 182: 23297 183: 367 184: 11777 185: 1481 186: 373 187: 11969 188: 1487939695262196876907983166454197495251350196192890428923003345454869706240895712896623468784438158657419591298913094265537812046389415279164757669092989298186306341246574002177 189: 379 190: 191 191: 383 192: 193 193: 773 194: 389 195: 3121 196: 197 197: 6455297 198: 199 199: 797 200: 401 201: 1609 202: 809 203: 1662977 204: 409 205: 821 206: 6750209 207: 829 208: 3329 209: 419 210: 211 211: 221249537 212: 1697 213: 853 214: 857 215: 431 216: 433 217: 16011773855979890802689 218: 6977 219: 439 220: 881 221: 443 222: 223 223: 57089 224: 449 225: 1801 226: 227 227: 464897 228: 229 229: 14657 230: 461 231: 463 232: 233 233: 467 234: 937 235: 941 236: 1889 237: 3793 238: 239 239: 479 240: 241 241: 16561393893377 242: 30977 243: 487 244: 977 245: 491 246: 7873 247: 15809 248: 7937 249: 499 250: 251 251: 503 252: 1009 253: 1013 254: 509 255: 1021 256: 257 257: 249632952651006185613150855026822179503549278818199928480857894651449200648869292015617 258: 1033 259: 71193377898497 260: 521 261: 523 262: 263 263: 141197049857 264: 2113 265: 1061 266: 2129 267: 1069 268: 269 269: 2153 270: 271 271: 4337 272: 557057 273: 547 274: 1097 275: 35201 276: 277 277: 1109 278: 557 279: 1117 280: 281 281: 563 282: 283 283: 303868936193 284: 569 285: 571 286: 1288029493427961857 287: 2297 288: 577 289: 295937 290: 9281 291: 4657 292: 293 293: 587 294: 37633 295: 1181 296: 593 297: 2377 298: 1193 299: 599 300: 601 301: 4817 302: 2417 303: 607 304: 1217 305: 2441 306: 307 307: 1229 308: 617 309: 619 310: 311 311: 159233 312: 313 313: 5009 314: 40193 315: 631 316: 317 317: 40577 318: 10177 319: 1277 320: 641 321: 643 322: 1289 323: 647 324: 1297 325: 1301 326: 653 327: 2617 328: 83969 329: 659 330: 331 331: 5297 332: 2657 333: 10657 334: 21377 335: 175636481 336: 337 337: 5393 338: 677 339: 2713 340: 1361 341: 683 342: 43777 343: 1373 344: 2753 345: 691 346: 347 347: 2777 348: 349 349: 357377 350: 701 351: 1437697 352: 353 353: 740294657 354: 709 355: 22721 356: 11393 357: 1429 358: 359 359: 719 360: 23041 361: 96905199617 362: 2897 363: 727 364: 23297 365: 11681 366: 367 367: 1503233 368: 11777 369: 739 370: 1481 371: 743 372: 373 373: 1493 374: 11969 375: 751 376: 1487939695262196876907983166454197495251350196192890428923003345454869706240895712896623468784438158657419591298913094265537812046389415279164757669092989298186306341246574002177 377: 772097 378: 379 379: 6209537 380: 761 381: 3049 382: 383 383: 11693945185971565896920916176753769281418376445302724140914106576604960252116205468905429628661873192664799900323401294531072465400997845029722990758855393414014415817179228695517839305455702961095094596926622802342799137107509767542153683280899327558274011281588755909890607960835140712630830933978801393590855371457894042968287926562847826310125559303901351824980311279986492793008248059208985097459095049075732193161126922389950080848742183055141518931962329796357335158955758486061360294773463111842316561192036096585088267052290025273980611139612478214293303564141730470933187279751846912161098280963960686648202780382930927114525552446602357404550468641236474238897222372272898562140228039886991631673186995098587756569010989657598363351856992206826342175536967926902668804937341514786382018872919876784539436965319822540039220122728568129762675989071883516915894567537630751801497223803135172643203770169327233350522822938630733126833423559124391441973547309619943019237705312515304113424366223388373606440335025932390399945086075175009569272136997988977568262327875607690344516747889133920438003737328060362069562108376086129279385800262195985974144460914705464874882401864174074796383557151951711000378565395148939760434428093058777242253682181813425273399277638142811972296863003382484684788329148214958434057306251885787781329925372401240556666727438408378656900945061970219566055969587385482421092779185798692904507774583223151161566406541599486350580593707153172641891804260963429951215526999443852964537303345106153870841180251403751871193132336680841124129779119999935597712685839886558769823834654994044516702436738265181698869580022472787153167463772595005393815295009535991557511340157179280662197799109181549751673455040271529561595718940092424231253150263268513067972937042222806102175350331146290864120703025608712817763221723427454002746818270565050919821097445991953785331131470462682015972815241620750337 384: 769 385: 98561 386: 773 387: 1549 388: 389 389: 796673 390: 3121 391: 6257 392: 3137 393: 787 394: 6455297 395: 12641 396: 397 397: 6353 398: 797 399: 1597 400: 401