How to resolve the algorithm Quad-power prime seeds step by step in the F# programming language
Published on 12 May 2024 09:40 PM
How to resolve the algorithm Quad-power prime seeds step by step in the F# programming language
Table of Contents
Problem Statement
Generate the sequence of quad-power prime seeds: positive integers n such that:
Let's start with the solution:
Step by Step solution about How to resolve the algorithm Quad-power prime seeds step by step in the F# programming language
Source code in the fsharp programming language
// Quad-power prime seeds. Nigel Galloway: August 22nd., 2022
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 1&&g 2&&g 3&&g 4)|>Seq.mapi(fun n g->(n,g))|>Seq.find(snd>>(<)g)
Seq.initInfinite((+)1)|>Seq.filter(fun n->let g=fG n in g 1&&g 2&&g 3&&g 4)|>Seq.take 50|>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 Gapful numbers step by step in the J programming language
You may also check:How to resolve the algorithm Strip a set of characters from a string step by step in the PL/I programming language
You may also check:How to resolve the algorithm Filter step by step in the Aime programming language
You may also check:How to resolve the algorithm Find palindromic numbers in both binary and ternary bases step by step in the VBA programming language
You may also check:How to resolve the algorithm Machine code step by step in the Quackery programming language