25 lines
669 B
FSharp
25 lines
669 B
FSharp
module _50
|
|
|
|
let sumOfConsequitivePrimes =
|
|
let ceiling = 1000000
|
|
let primes = common.primeArray ceiling
|
|
let isPrime = common.isPrimeFunByArray primes
|
|
|
|
let primeSumUnderCeilingIndex =
|
|
primes
|
|
|> Seq.scan (fun state p -> p + state) 0
|
|
|> Seq.findIndex (fun s -> s > ceiling)
|
|
|> (+) -1
|
|
|
|
let indiciesOfDecendingLength max =
|
|
seq {
|
|
for l in max .. -1 .. 0 do
|
|
for o in 0 .. (max - l) do
|
|
yield (o, l)
|
|
}
|
|
|
|
indiciesOfDecendingLength primeSumUnderCeilingIndex
|
|
|> Seq.map (fun (start,len) -> Array.sub primes start len |> Array.sum)
|
|
|> Seq.find isPrime
|
|
|