initial commit
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
module _37
|
||||
|
||||
let truncations i =
|
||||
let s = string i
|
||||
let len = s.Length
|
||||
seq {
|
||||
for n in 0..(len - 1) do
|
||||
yield s.Substring(0, len - n)
|
||||
if (n > 0) then
|
||||
yield s.Substring(len - n)
|
||||
} |> Seq.distinct |> Seq.toList |> List.map (int)
|
||||
|
||||
let truncatablePrimes =
|
||||
let oddOr2 i = i % 2 = 1 || i = 2
|
||||
|
||||
let pa =
|
||||
common.primeArray 1000000
|
||||
|> Array.filter (common.numDigits >> (Array.forall oddOr2))
|
||||
|
||||
let isPrime n = Array.exists (fun p -> p = n) pa
|
||||
pa
|
||||
|> Array.filter ((<) 10)
|
||||
|> Array.map truncations
|
||||
|> Array.filter (List.forall isPrime)
|
||||
|> Array.map (Seq.nth 0)
|
||||
|> Array.sum
|
||||
Reference in New Issue
Block a user