| Changes to /trunk/Fsharp/euler14.fs |
r0 vs. r5
Edit
|
r5
|
| /trunk/Fsharp/euler14.fs | /trunk/Fsharp/euler14.fs r5 | ||
| 1 | let seq_length n = n > Seq.unfold(fun x -> match x with | ||
|---|---|---|---|
| 2 | x when x = 0L -> None | ||
| 3 | x when x = 1L -> Some((1L,0L)) | ||
| 4 | x when x%2L=0L -> Some((x,x/2L)) | ||
| 5 | _ -> Some((x,3L*x + 1L)) | ||
| 6 | ) > Seq.length | ||
| 7 | [for i in 1L..1000000L -> (i, seq_length i)] | ||
| 8 | > List.fold1_left(fun (ai,al) (i,l) -> if l > al then (i,l) else (ai,al) ) | ||
| 9 | > (fun (x,y) -> x ) > print_any | ||