1
2
3
4
5
6
b :: Integer -> Integer
b 0 = 0
b x = b' x + 2 * b (div x 10)
    where b' x = if odd x then 1 else 0

main = print $ b 01101001  -- 10