Length is indexed by 1, start counts there
parent
956e56028f
commit
a3dda37643
|
@ -7,7 +7,7 @@ import Control.Monad ()
|
|||
import Debug.Trace (trace)
|
||||
|
||||
f' :: Integer -> Integer
|
||||
f' n = f'' 0 n
|
||||
f' n = f'' 1 n
|
||||
where
|
||||
f'' :: Integer -> Integer -> Integer
|
||||
f'' i n'
|
||||
|
@ -19,14 +19,13 @@ f' n = f'' 0 n
|
|||
t'' = trace "\n#######################################################\n"
|
||||
|
||||
f :: Integer -> Integer
|
||||
f n = s 0 n
|
||||
f n = s 1 n
|
||||
where
|
||||
s :: Integer -> Integer -> Integer
|
||||
s i n
|
||||
| n == 1 = i
|
||||
| even n = s i' (n `div` 2)
|
||||
| odd n = s i' (3*n + 1)
|
||||
where i' = succ i
|
||||
| even n = s (succ i) (n `div` 2)
|
||||
| odd n = s (succ i) (3*n + 1)
|
||||
|
||||
main :: IO ()
|
||||
main = print $ map f [2^361..]
|
||||
|
|
Loading…
Reference in New Issue