Fortunate numbers: Difference between revisions

Content added Content deleted
m (simpler)
m (make output a clone of others)
Line 109: Line 109:
fortunate(n) = nextprime(primorial[n] + 2) - primorial[n]
fortunate(n) = nextprime(primorial[n] + 2) - primorial[n]


println("After sorting, the first 50 distinct fortunate numbers are:")
foreach(p -> print(rpad(last(p), 5), first(p) % 10 == 0 ? "\n" : ""),
foreach(p -> print(rpad(last(p), 5), first(p) % 10 == 0 ? "\n" : ""),
(map(fortunate, 1:100) |> unique |> sort!)[begin:50] |> enumerate)
(map(fortunate, 1:100) |> unique |> sort!)[begin:50] |> enumerate)
</lang>{{out}}
</lang>{{out}}
<pre>
<pre>
After sorting, the first 50 distinct fortunate numbers are:
3 5 7 13 17 19 23 37 47 59
3 5 7 13 17 19 23 37 47 59
61 67 71 79 89 101 103 107 109 127
61 67 71 79 89 101 103 107 109 127