How to resolve the algorithm Ormiston triples step by step in the F# programming language

Published on 12 May 2024 09:40 PM

How to resolve the algorithm Ormiston triples step by step in the F# programming language

Table of Contents

Problem Statement

An Ormiston triple is three consecutive prime numbers which are anagrams, i.e. contain the same decimal digits but in a different order. The three consecutive primes (11117123, 11117213, 11117321) are an Ormiston triple.

Let's start with the solution:

Step by Step solution about How to resolve the algorithm Ormiston triples step by step in the F# programming language

Source code in the fsharp programming language

// 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}"


  

You may also check:How to resolve the algorithm Day of the week step by step in the Bracmat programming language
You may also check:How to resolve the algorithm Factorions step by step in the Delphi programming language
You may also check:How to resolve the algorithm Perfect numbers step by step in the Lasso programming language
You may also check:How to resolve the algorithm Menu step by step in the Fortran programming language
You may also check:How to resolve the algorithm Simulate input/Keyboard step by step in the OCaml programming language