public class JavaExample { public static void main(String[] args) { int num = 370, number, temp, total = 0; number = num; while (number != 0) { temp = number % 10; total = total + temp*temp*temp; number /= 10; } if(total == num) System.out.println(num + " is an Armstrong number"); else System.out.println(num + " is not an Armstrong number"); } }
Java Program to check whether the given number is Armstrong number.
Reviewed by
on
December 20, 2019
Rating:

No comments: