26 lines
735 B
FSharp
26 lines
735 B
FSharp
module _69
|
|
|
|
open common
|
|
|
|
let relativePrimeFunc =
|
|
|
|
let primeDivisorArrayByMax max =
|
|
let isPrime = isPrimeFunByMax (int (System.Math.Ceiling(sqrt (float max))))
|
|
divisorsInclSelf max |> Array.map (List.filter isPrime)
|
|
|
|
let totientArrayByMax max =
|
|
let pd = primeDivisorArrayByMax max
|
|
let productFormula n primes =
|
|
let pFunc prime = 1.0 - 1.0/(float prime)
|
|
primes
|
|
|> List.fold (fun p prime -> p * (pFunc prime)) (float n)
|
|
pd
|
|
|> Array.mapi productFormula
|
|
|
|
let indexArray = Array.mapi (fun i e -> (i,e))
|
|
|
|
totientArrayByMax 1000000
|
|
|> indexArray
|
|
|> Seq.skip 1
|
|
|> Seq.map (fun (i,t) -> (i, (float i)/t))
|
|
|> Seq.maxBy snd |