Created
October 9, 2009 02:21
-
-
Save dahlbyk/205639 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let GetChainLength value = | |
let next x = match x % 2L with | |
| 0L -> x / 2L | |
| _ -> x * 3L + 1L | |
let rec chain n acc = match n with | |
| x when x <= 1L -> acc | |
| x -> chain (next x) (acc+1) | |
value, (chain value 1) | |
seq { 1L..999999L } | |
|> Seq.map GetChainLength | |
|> Seq.maxBy snd |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment