RosettaCodeData/Task/Magnanimous-numbers/F-Sharp/magnanimous-numbers-1.fs
2023-07-01 13:44:08 -04:00

6 lines
403 B
FSharp
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

// Generate Magnanimous numbers. Nigel Galloway: March 20th., 2020
let rec fN n g = match (g/n,g%n) with
(0,_) -> true
|(α,β) when isPrime (α+β) -> fN (n*10) g
|_ -> false
let Magnanimous = let Magnanimous = fN 10 in seq{yield! {0..9}; yield! Seq.initInfinite id |> Seq.skip 10 |> Seq.filter Magnanimous}