- Posted By: pradeeshtet
- Comments: 0

simple java program to display armstrong number. What is armstrong number - In armstrong number sum of cubes of its digits is equal to the number itself.__Example 1:__ **153 **- 1^3+5^ 3+ 3^ 3 =1+125+27= 153, therefore **153 **is armstrong number.__Example 2: __125 - 1^ 3+2^ 3+5^ 3= 1+8+125=134, therefore 125 is not an armstrong number.

The code check the number given by user is amrstrong number or not .

class Armstrong { public static void main(String args[]) { int n=153; int armst=n; while(n > 0) { x=n%10; s=s+(x*x*x); n=n/10; } if(armst==s) { System.out.println(“Given number is armstrong”); } else { System.out.println(“It is not an armstrong number”); } } }

**Explanation:**

The logic is similar to the logic used in the reverse the number program, so refer here.

**Above code display the following output:**

Given number is armstrong