initial commit
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
module _92
|
||||
|
||||
open common
|
||||
|
||||
let squareChainLoop =
|
||||
|
||||
let squareDigits d =
|
||||
let square n = n * n
|
||||
d |> numDigits |> Seq.map square |> Seq.sum
|
||||
|
||||
let chainDict = new System.Collections.Generic.Dictionary<int,int>()
|
||||
let rec chainCache = function
|
||||
| x when chainDict.ContainsKey(x) -> chainDict.[x]
|
||||
| 1 -> 1
|
||||
| 89 -> 89
|
||||
| x -> chainDict.[x] <- chainCache (squareDigits x); chainDict.[x]
|
||||
|
||||
allIntegers |> Seq.skip 1 |> Seq.takeWhile ((>) 10000000)
|
||||
|> Seq.map chainCache
|
||||
|> Seq.filter ((=) 89)
|
||||
|> Seq.length
|
||||
|
||||
Reference in New Issue
Block a user