Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
6
Task/Smith-numbers/F-Sharp/smith-numbers.fs
Normal file
6
Task/Smith-numbers/F-Sharp/smith-numbers.fs
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
// Generate Smith Numbers. Nigel Galloway: November 6th., 2020
|
||||
let fN g=Seq.unfold(fun n->match n with 0->None |_->Some(n%10,n/10)) g |> Seq.sum
|
||||
let rec fG(n,g) p=match g%p with 0->fG (n+fN p,g/p) p |_->(n,g)
|
||||
primes32()|>Seq.pairwise|>Seq.collect(fun(n,g)->[n+1..g-1])|>Seq.takeWhile(fun n->n<10000)
|
||||
|>Seq.filter(fun g->fN g=fst(primes32()|>Seq.scan(fun n g->fG n g)(0,g)|>Seq.find(fun(_,n)->n=1)))
|
||||
|>Seq.chunkBySize 20|>Seq.iter(fun n->Seq.iter(printf "%4d ") n; printfn "")
|
||||
Loading…
Add table
Add a link
Reference in a new issue