daily pastebin goal
40%
SHARE
TWEET

Untitled

a guest Dec 9th, 2018 58 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top