-- blockSize m b = the number of base-b digits that can be represented by
-- an Integer < m. Hint: calculate this by repeatedly multiplying 1 by b
-- until you get >= m, returning one less than the number of multiplications
blockSize :: Integer -> Int -> Int
blockSize m b = mult' 1 0
where mult' a c
| a >= m = c-1
| otherwise = mult' (a * toInteger b) (c+1)
Comments