How to resolve the algorithm Penta-power prime seeds step by step in the F# programming language

Published on 12 May 2024 09:40 PM

How to resolve the algorithm Penta-power prime seeds step by step in the F# programming language

Table of Contents

Problem Statement

Generate the sequence of penta-power prime seeds: positive integers n such that:

I can find no mention or record of this sequence anywhere. Perhaps I've invented it.

Let's start with the solution:

Step by Step solution about How to resolve the algorithm Penta-power prime seeds step by step in the F# programming language

Source code in the fsharp programming language

// Penta-power prime seeds. Nigel Galloway: April 5th., 2023
let fG n g=let n=bigint(n:int) in let n=n**g+n+1I in Open.Numeric.Primes.MillerRabin.IsProbablePrime &n
let fN(n,g)=Seq.initInfinite((+)n)|>Seq.filter(fun n->let g=fG n in g 0&&g 1&&g 2&&g 3&&g 4)|>Seq.mapi(fun n g->(n,g))|>Seq.find(snd>>(<)g)
Seq.initInfinite((*)2>>(+)1)|>Seq.filter(fun n->let g=fG n in g 0&&g 1&&g 2&&g 3&&g 4)|>Seq.take 30|>Seq.iter(printf "%d "); printfn "\n"
[1000000..1000000..10000000]|>Seq.scan(fun(n,g,x) l->let i,e=fN(g,l) in (n+i,e,l))(0,0,0)|>Seq.skip 1|>Seq.iter(fun(n,g,l)->printfn $"First element over %8d{l} is %9d{g} at index %3d{n}")


  

You may also check:How to resolve the algorithm Roman numerals/Encode step by step in the Ceylon programming language
You may also check:How to resolve the algorithm Add a variable to a class instance at runtime step by step in the Raku programming language
You may also check:How to resolve the algorithm Elementary cellular automaton step by step in the Octave programming language
You may also check:How to resolve the algorithm Binary search step by step in the PicoLisp programming language
You may also check:How to resolve the algorithm Address of a variable step by step in the Smalltalk programming language