Repunit primes: Difference between revisions
Content added Content deleted
(Realize in F#) |
|||
Line 49: | Line 49: | ||
=={{header|F_Sharp|F#}}== |
|||
===The function=== |
|||
This task uses [http://www.rosettacode.org/wiki/Extensible_prime_generator#The_functions Extensible Prime Generator (F#)] |
|||
<lang fsharp> |
|||
// Repunit primes. Nigel Galloway: January 24th., 2022 |
|||
let rUnitP(b:int)=let b=bigint b in primes32()|>Seq.takeWhile((>)1000)|>Seq.map(fun n->(n,((b**n)-1I)/(b-1I)))|>Seq.filter(fun(_,n)->Open.Numeric.Primes.MillerRabin.IsProbablePrime &n)|>Seq.map fst |
|||
[2..16]|>List.iter(fun n->printf $"Base %d{n}: "; let n=rUnitP n in n|>Seq.iter(printf "%d "); printfn "") |
|||
</lang> |
|||
{{out}} |
|||
<pre> |
|||
Base 2: 2 3 5 7 13 17 19 31 61 89 107 127 521 607 |
|||
Base 3: 3 7 13 71 103 541 |
|||
Base 4: 2 |
|||
Base 5: 3 7 11 13 47 127 149 181 619 929 |
|||
Base 6: 2 3 7 29 71 127 271 509 |
|||
Base 7: 5 13 131 149 |
|||
Base 8: 3 |
|||
Base 9: |
|||
Base 10: 2 19 23 317 |
|||
Base 11: 17 19 73 139 907 |
|||
Base 12: 2 3 5 19 97 109 317 353 701 |
|||
Base 13: 5 7 137 283 883 991 |
|||
Base 14: 3 7 19 31 41 |
|||
Base 15: 3 43 73 487 |
|||
Base 16: 2 |
|||
</pre> |
|||
=={{header|Julia}}== |
=={{header|Julia}}== |
||
<lang julia>using Primes |
<lang julia>using Primes |
||
Line 99: | Line 125: | ||
Base 40: [2, 5, 7, 19, 23, 29, 541, 751, 1277] |
Base 40: [2, 5, 7, 19, 23, 29, 541, 751, 1277] |
||
</pre> |
</pre> |
||
=={{header|Phix}}== |
=={{header|Phix}}== |