initial commit
This commit is contained in:
@@ -0,0 +1,15 @@
|
||||
module _14
|
||||
|
||||
let collatzConjecture n =
|
||||
match n with
|
||||
| 0L -> None
|
||||
| 1L -> Some(1L,0L)
|
||||
| n -> Some(n,
|
||||
if n % 2L = 0L then n/2L
|
||||
else if n % 2L = 1L then 3L*n + 1L
|
||||
else 1L)
|
||||
|
||||
let getLongestChain =
|
||||
[1L..1000000L]
|
||||
|> Seq.map (fun i -> (i |> Seq.unfold collatzConjecture |> Seq.length, i))
|
||||
|> Seq.max
|
||||
Reference in New Issue
Block a user