user
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. *Specifically term 383.*

See also

A050921 - Smallest prime of form n\*2^m+1
assistant
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 { printf "%3d %4d: %d\n",$n,$m,$p; last } } } for 1..400

```

Output:

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