# JAVA PROGRAM TO FIND ARMSTRONG NUMBER IN JAVA

ARMSTRONG NUMBER: Armstrong number is a Number whose sum of the cubes of its digits should be equal to the actual Number. A number should be a positve Number.

Example : 371 is an Armstrong Number since cube of its individual digit is equal to the actual Number.

`371 = (3*3*3)+(7*7*7)+(1*1*1)3*3*3 = 277*7*7 = 3431*1*1 = 127+343+1 = 371`

[hide]
• Java Program to find Armstrong using while loop
• Java Program to find Armstrong using for loop

### Example 1 : Java Program to generate fibonacci series of a number using while loop

``````//Java Program to find Armstrong Number using while loop
import java.util.Scanner;
class ArmstrongDemo{
public static int findArmstrong(int num){
int m=0; int n=0;
while(num>0){
n=num%10;
num=num/10;
m=m+(n*n*n);
}
return m;
}
}

public class Codebator{
public static void main(String[] args){
Scanner sc=new Scanner(System.in);
System.out.println("Enter any number");
int inputnum=sc.nextInt();
int getresult=ArmstrongDemo.findArmstrong(inputnum);

if(inputnum==getresult){
System.out.print("It is a Armstrong number");
}
else{
System.out.print("It is not a Armstrong number");
}
}
}
``````

#### OUTPUT :

`Enter any Number371 It is a Armstrong number `

### Example 1 : Java Program to generate fibonacci series of a number using for loop

``````//Java Program to find Armstrong Number using for loop
import java.util.Scanner;
class ArmstrongDemo{
public static int findArmstrong(int num){
int m=0; int n=0;
for(;num!=0;num=num/10){
n=num%10;
m=m+(n*n*n);
}
return m;
}
}

public class Codebator{
public static void main(String[] args){
Scanner sc=new Scanner(System.in);
System.out.println("Enter any number");
int inputnum=sc.nextInt();
int getresult=ArmstrongDemo.findArmstrong(inputnum);

if(inputnum==getresult){
System.out.print("It is a Armstrong number");
}
else{
System.out.print("It is not a Armstrong number");
}
}
}
``````

#### OUTPUT :

`Enter any Number546 It is not a Armstrong number `