Pierpont primes: Difference between revisions

Realize in F#
(Added Delphi exemple)
(Realize in F#)
Line 744:
readln;
end.</lang>
=={{header|F_Sharp|F#}}==
This task uses [[Extensible_prime_generator#The_functions|Extensible Prime Generator (F#)]].<br>
<lang fsharp>
// Pierpont primes . Nigel Galloway: March 19th., 2021
let fN g=let mutable g=g in ((fun()->g),fun()->g<-g+g;())
let fG y=let rec fG n g=seq{match g|>List.minBy(fun(n,_)->n()) with (f,s) when f()=n->yield f()+y; s(); yield! fG(n*3)(fN(n*3)::g)
|(f,s) ->yield f()+y; s(); yield! fG n g}
seq{yield! fG 1 [fN 1]}|>Seq.filter isPrime
let pierpontT1,pierpontT2=fG 1,fG -1
 
pierpontT1|>Seq.take 50|>Seq.iter(printf "%d "); printfn ""
pierpontT2|>Seq.take 50|>Seq.iter(printf "%d "); printfn ""
</lang>
{{out}}
<pre>
2 3 5 7 13 17 19 37 73 97 109 163 193 257 433 487 577 769 1153 1297 1459 2593 2917 3457 3889 10369 12289 17497 18433 39367 52489 65537 139969 147457 209953 331777 472393 629857 746497 786433 839809 995329 1179649 1492993 1769473 1990657 2654209 5038849 5308417 8503057
2 3 5 7 11 17 23 31 47 53 71 107 127 191 383 431 647 863 971 1151 2591 4373 6143 6911 8191 8747 13121 15551 23327 27647 62207 73727 131071 139967 165887 294911 314927 442367 472391 497663 524287 786431 995327 1062881 2519423 10616831 17915903 18874367 25509167 30233087
</pre>
=={{header|Factor}}==
<lang factor>USING: fry grouping io kernel locals make math math.functions
2,171

edits