# Pastebin xnr2HpyW lifetimeOf :: Integer -> Integer -> Integer lifetimeOf k n = if x == n then k * n else lifetimeOf k (n - x) where x = 2 ^ (floor (logBase 2 (fromIntegral n) :: Double) :: Integer)