clairec icon

Untitled

clairec | PRO | 09/27/16 08:42:42 PM UTC | 0 ⭐ | 479 👁️ | Never ⏰ | []
text |

380 B

|

None

|

0 👍

/

0 👎

-- 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