Jump to content

Ormiston triples: Difference between revisions

Realize in F#
(Added C++ solution)
(Realize in F#)
Line 98:
</pre>
 
=={{header|F_Sharp|F#}}==
This task uses [[Ormiston_pairs#F#]]
<syntaxhighlight lang="fsharp">
// Ormiston triples. Nigel Galloway: February 3rd., 2023
let oTriples n=n|>Seq.pairwise|>Seq.filter(fun((n,i),(g,l))->i=g)|>Seq.map(fun((n,i),(g,l))->(n,g,l))
primes32()|>oPairs|>oTriples|>Seq.take 25|>Seq.iter(fun(n,_,_)->printf "%d " n); printfn ""
printfn $"<100 million: %d{primes32()|>Seq.takeWhile((>)100000000)|>oPairs|>oTriples|>Seq.length}"
printfn $"<1 billion: %d{primes32()|>Seq.takeWhile((>)1000000000)|>oPairs|>oTriples|>Seq.length}"
</syntaxhighlight>
{{out}}
<pre>
11117123 12980783 14964017 32638213 32964341 33539783 35868013 44058013 46103237 48015013 50324237 52402783 58005239 60601237 61395239 74699789 76012879 78163123 80905879 81966341 82324237 82523017 83279783 86050781 92514341
<100 million: 25
<1 billion: 368
</pre>
=={{header|Go}}==
{{trans|Wren}}
2,172

edits

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