1
0
Fork 0
mirror of https://gitlab.com/mfocko/CodeWars.git synced 2024-11-09 02:59:06 +01:00
CodeWars/6kyu/does_my_number_look_big_in_this/solution.cs

20 lines
420 B
C#
Raw Normal View History

using System;
public class Kata {
public static bool Narcissistic(int value) {
var narcissistic = 0;
var length = (int) Math.Log10(value + 0.5) + 1;
var copyOfValue = value;
while (copyOfValue > 0) {
narcissistic += (int) Math.Pow(copyOfValue % 10, length);
copyOfValue /= 10;
if (narcissistic > value) {
return false;
}
}
return narcissistic == value;
}
}