Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
import kotlin.math.pow
override fun isNarcisstic(num: Int): Boolean {
return when {
num < 10 -> true
num < 100 -> false
else -> num == ("" + num).chars()
.map { cp -> Character.getNumericValue(cp).toDouble().pow(("" + num).length.toDouble()).toInt() }
.sum()
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment