Cómo encontrar números de Armstrong en Java
public static void printArmstrongOrNot(int num) {
int temp = num;
int cubeValue = 0;
while (num != 0) {
cubeValue += (num % 10) * (num % 10) * (num % 10);
num /= 10;
}
if (cubeValue == temp) {
System.out.println(temp + " is an armstrong number");
} else {
System.out.println(temp + " is not an armstrong number");
}
}
public static void main(String args[]) {
printArmstrongOrNot(371);
printArmstrongOrNot(372);
}
Chathumal Sangeeth