Program To Find Whether This Number is Armstrong Number or Not In Java.

Program To Find Armstrong Number..

 class ArmstrongNumber
{  
  public static void main(String[] args)
  {  
    int c=0,a,temp; 
 
    int n=153;//It is the number to check armstrong  

    temp=n;  

    while(n>0)  
    {  
    a=n%10;  

    n=n/10;  

    c=c+(a*a*a);  
    }  
    if(temp==c)  
    System.out.println("armstrong number");  
 
    else  
        System.out.println("Not armstrong number");   
   }  
} 
 
 /*Output:
 armstrong number
 */

You may also like...

0 0 vote
Article Rating
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x