Skip to content

Instantly share code, notes, and snippets.

@cesare
Created January 8, 2010 16:20
Show Gist options
  • Save cesare/272154 to your computer and use it in GitHub Desktop.
Save cesare/272154 to your computer and use it in GitHub Desktop.
sumDigits n = foldl (+) 0 (splitNumber n)
where splitNumber x | x < 10 = [x]
| otherwise = ((mod x 10):splitNumber (div x 10))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment