n % 9 is such an interesting property! But since I had no knowledge of it, I went with a naive solution in KOTLIN which I cracked within a few minutes:
fun digitalRoot(number: Int): Int {
return if(number < 10) {
number
} else {
val digits = number.toString().split("")
var sum = 0
digits.forEach {
val digit = it.toIntOrNull()
if(digit != null) { sum += digit}
}
digitalRoot(sum)
}
}
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
n % 9
is such an interesting property! But since I had no knowledge of it, I went with a naive solution in KOTLIN which I cracked within a few minutes: