daily pastebin goal
88%
SHARE
TWEET

Untitled

a guest Jan 23rd, 2018 50 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.     sumDigits :: Int -> Int
  2.      -- Adds together each digit of given number
  3.  
  4.     sumDigits n
  5.    
  6.       | n <= 9   = n
  7.       | n >= 10  = ( n `mod` 10 ) + sumDigits ( n `div` 10 )
  8.  
  9.  
  10.     sumAllDigits :: [Int] -> Int
  11.      -- Adds together each digit of given list
  12.  
  13.     sumAllDigits []         = 0
  14.     sumAllDigits ( x : xs ) = ( SumDigits x ) + ( sumAllDigits xs )
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