Advertisement
AndrewHaxalot

Find Whether a Number is Armstrong or Not

Dec 1st, 2013
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.27 KB | None | 0 0
  1. class Armstrong
  2. {
  3. public static void main(String...s)
  4. {
  5. int m,n,i,j=0;
  6. n=Integer.parseInt(s[0]);
  7.  
  8. m=n;
  9. while(n!=0)
  10. {
  11. i=n%10;
  12. j+=(i*i*i);
  13. n/=10;
  14. }
  15.  
  16. if(j==m)
  17. System.out.println("\nNumber is armstrong");
  18. else
  19. System.out.println("\nNumber is not armstrong");
  20. }
  21. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement