Fermat pseudoprimes: Difference between revisions
m
→{{header|F_Sharp|F#}}: Change O -> 0. Didn't really matter but bothered me
Thundergnat (talk | contribs) m (Typo, white space, massage link, add another) |
Thundergnat (talk | contribs) m (→{{header|F_Sharp|F#}}: Change O -> 0. Didn't really matter but bothered me) |
||
Line 59:
// Fermat pseudoprimes. Nigel Galloway: August 17th., 2022
let fp(a:int)=let a=bigint a in primesI()|>Seq.pairwise|>Seq.collect(fun(n,g)->seq{for n in n+1I..g-1I do if bigint.ModPow(a,n-1I,n)=1I then yield n})
{1..20}|>Seq.iter(fun n->printf $"Base %2d{n} - Up to 50000: %5d{fp n|>Seq.takeWhile((>=)50000I)|>Seq.length} First
</lang>
{{out}}
<pre>
Base 1 - Up to 50000: 44866 First
Base 2 - Up to 50000: 55 First
Base 3 - Up to 50000: 53 First
Base 4 - Up to 50000: 111 First
Base 5 - Up to 50000: 54 First
Base 6 - Up to 50000: 74 First
Base 7 - Up to 50000: 49 First
Base 8 - Up to 50000: 150 First
Base 9 - Up to 50000: 113 First
Base 10 - Up to 50000: 65 First
Base 11 - Up to 50000: 61 First
Base 12 - Up to 50000: 91 First
Base 13 - Up to 50000: 68 First
Base 14 - Up to 50000: 69 First
Base 15 - Up to 50000: 42 First
Base 16 - Up to 50000: 145 First
Base 17 - Up to 50000: 63 First
Base 18 - Up to 50000: 98 First
Base 19 - Up to 50000: 93 First
Base 20 - Up to 50000: 66 First
Real: 00:00:00.632
</pre>
=={{header|Julia}}==
<lang ruby>using Primes
|