Last active
May 28, 2020 22:16
-
-
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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