1
0
Fork 0
mirror of https://gitlab.com/mfocko/CodeWars.git synced 2024-11-08 18:49:07 +01:00
CodeWars/6kyu/does_my_number_look_big_in_this/solution.cs
Matej Focko fc899b0b02
chore: initial commit
Signed-off-by: Matej Focko <mfocko@redhat.com>
2021-12-28 16:19:58 +01:00

19 lines
420 B
C#

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;
}
}