DEV Community

Discussion on: Haskell program answer please

Collapse
shashwatseth profile image
Shashwat Seth

dropOdds :: Int -> Int
dropOdds x
| x > 10 = 10 * dropOdds restDigits + dropOdds firstDigit
| otherwise = dropOddsOneDigit x
where
firstDigit = x mod 10
restDigits = x div 10

dropOddsOneDigit x
| x mod 2 == 0 = x
| otherwise = 0