Jump to content

Wagstaff primes: Difference between revisions

Realize in F#
(Realize in F#)
Line 81:
 
 
=={{header|F_Sharp|F#}}==
This task uses [http://www.rosettacode.org/wiki/Extensible_prime_generator#The_functions Extensible Prime Generator (F#)]
<syntaxhighlight lang="fsharp">
// Wagstaff primes. Nigel Galloway: September 15th., 2022
let isWagstaff n=let mutable g=(1I+2I**n)/3I in if Open.Numeric.Primes.MillerRabin.IsProbablePrime &g then Some (n,g) else None
primes32()|>Seq.choose isWagstaff|>Seq.take 10|>Seq.iter(fun (n,g)->printfn $"%d{n}->%A{g}")
primes32()|>Seq.choose isWagstaff|>Seq.skip 10|>Seq,take 14|>Seq.iter(fun(n,_)->printf $"%d{n} "); printfn ""
</syntaxhighlight>
{{out}}
<pre>
3->3
5->11
7->43
11->683
13->2731
17->43691
19->174763
23->2796203
31->715827883
43->2932031007403
 
61 79 101 127 167 191 199 313 347 701 1709 2617 3539 5807
</pre>
=={{header|Python}}==
<syntaxhighlight lang="python">""" Rosetta code Wagstaff_primes task """
2,172

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.