Skip to content

Instantly share code, notes, and snippets.

@TheAlienMann
Last active September 14, 2020 09:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save TheAlienMann/ccf94cf519505d7c6734b8c4ca59447a to your computer and use it in GitHub Desktop.
Save TheAlienMann/ccf94cf519505d7c6734b8c4ca59447a to your computer and use it in GitHub Desktop.
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