Guest User

Untitled

a guest
Dec 9th, 2018
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.35 KB | None | 0 0
  1. reduceADigito :: Int -> Int
  2. reduceADigito x
  3. | x < 10 = x
  4. | otherwise = reduceADigito $ sumaDigitos $ obtenDigitos x
  5.  
  6. sumaDigitos :: [Int] -> Int
  7. sumaDigitos [] = 0
  8. sumaDigitos (x:xs) = x + sumaDigitos xs
  9.  
  10. obtenDigitos :: Int -> [Int]
  11. obtenDigitos 0 = []
  12. obtenDigitos x = y : obtenDigitos ( ( x - y ) `div` 10 )
  13. where y = x `mod` 10
Add Comment
Please, Sign In to add comment