Skip to content

Instantly share code, notes, and snippets.

@jluismm2311
Last active May 28, 2020 22:16
Show Gist options
  • Save jluismm2311/1f5e40dd453716636f6b5e9831de9679 to your computer and use it in GitHub Desktop.
Save jluismm2311/1f5e40dd453716636f6b5e9831de9679 to your computer and use it in GitHub Desktop.
Write a function named sumDigits which takes a number as input and returns the sum of the absolute value of each of the number's decimal digits.
class Kata{
static int sumDigits(number) {
"${number.abs()}".toList().collect{it.toInteger()}.value.sum()
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment