Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- reduceADigito :: Int -> Int
- reduceADigito x
- | x < 10 = x
- | otherwise = reduceADigito $ sumaDigitos $ obtenDigitos x
- sumaDigitos :: [Int] -> Int
- sumaDigitos [] = 0
- sumaDigitos (x:xs) = x + sumaDigitos xs
- obtenDigitos :: Int -> [Int]
- obtenDigitos 0 = []
- obtenDigitos x = y : obtenDigitos ( ( x - y ) `div` 10 )
- where y = x `mod` 10
Add Comment
Please, Sign In to add comment