package Maths;
public class Armstrong {
public static void main(String[] args) {
assert (isArmStrong(0));
assert (isArmStrong(1));
assert (isArmStrong(153));
assert (isArmStrong(1634));
assert (isArmStrong(371));
assert (!isArmStrong(200));
}
private static boolean isArmStrong(int number) {
int sum = 0;
int temp = number;
int numberOfDigits = 0;
while (temp != 0) {
numberOfDigits++;
temp /= 10;
}
temp = number;
while (number > 0) {
int remainder = number % 10;
int power = 1;
for (int i = 1; i <= numberOfDigits; power *= remainder, ++i)
;
sum = sum + power;
number /= 10;
}
return sum == temp;
}
}