Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- sumDigits :: Int -> Int
- -- Adds together each digit of given number
- sumDigits n
- | n <= 9 = n
- | n >= 10 = ( n `mod` 10 ) + sumDigits ( n `div` 10 )
- sumAllDigits :: [Int] -> Int
- -- Adds together each digit of given list
- sumAllDigits [] = 0
- sumAllDigits ( x : xs ) = ( SumDigits x ) + ( sumAllDigits xs )
Add Comment
Please, Sign In to add comment