DEV Community

Discussion on: Daily Challenge #195 - No Zeroes for Heroes

Collapse
 
craigmc08 profile image
Craig McIlwrath • Edited

Recursive Haskell solution

eradicateTrailingZeroes :: (Integral a) => a -> a
eradicateTrailingZeroes 0 = 0
eradicateTrailingZeroes n
  | n `rem` 10 == 0 = eradicateTrailingZeroes $ n `quot` 10
  | otherwise       = n
Collapse
 
avalander profile image
Avalander

Does this work when passing 0 as argument?

Collapse
 
craigmc08 profile image
Craig McIlwrath

Good catch, guess I missed that case. Updated it.