Showing posts with label Armstrong. Show all posts
Showing posts with label Armstrong. Show all posts

Tuesday, 10 September 2013

Java Program to find out entered number is armstrong or not through Commandline

class Arm
{
     public static void main(String ar[])
     {
          int num=Integer.parseInt(ar[0]);
          int n=num;
          int check=0,remainder;
          
          while(num>0)
          {
               remainder=num%10;
               check=check+(int) Math.pow(remainder,3);
               num=num/10;
          }
          
          if(check==n)
          {
               System.out.println("This is armstrong number");
          }
          else
          {
               System.out.println("This is not armstrong number");
          }
     }
}


Output: