Coprime triplets: Difference between revisions
Content added Content deleted
SqrtNegInf (talk | contribs) (Added Perl) |
(Realize in F#) |
||
Line 131: | Line 131: | ||
<lang applescript>{1, 2, 3, 5, 4, 7, 9, 8, 11, 13, 6, 17, 19, 10, 21, 23, 16, 15, 29, 14, 25, 27, 22, 31, 35, 12, 37, 41, 18, 43, 47, 20, 33, 49, 26, 45}</lang> |
<lang applescript>{1, 2, 3, 5, 4, 7, 9, 8, 11, 13, 6, 17, 19, 10, 21, 23, 16, 15, 29, 14, 25, 27, 22, 31, 35, 12, 37, 41, 18, 43, 47, 20, 33, 49, 26, 45}</lang> |
||
=={{header|F_Sharp|F#}}== |
|||
<lang fsharp> |
|||
// Coprime triplets: Nigel Galloway. May 12th., 2021 |
|||
let rec fN g=function 0->g=1 |n->fN n (g%n) |
|||
let rec fG t n1 n2=seq{let n=seq{1..0x0FFFFFFF}|>Seq.find(fun n->not(List.contains n t) && fN n1 n && fN n2 n) in yield n; yield! cT(n::t) n2 n} |
|||
let cT=seq{yield 1; yield 2; yield! fG [1;2] 1 2} |
|||
cT|>Seq.takeWhile((>)50)|>Seq.iter(printf "%d "); printfn "" |
|||
</lang> |
|||
{{out}} |
|||
<pre> |
|||
1 2 3 5 4 7 9 8 11 13 6 17 19 10 21 23 16 15 29 14 25 27 22 31 35 12 37 41 18 43 47 20 33 49 26 45 |
|||
</pre> |
|||
=={{header|Factor}}== |
=={{header|Factor}}== |
||
{{works with|Factor|0.99 2021-02-05}} |
{{works with|Factor|0.99 2021-02-05}} |