954,545 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?

Armstrong Numbers

By raj26061990 on Aug 16th, 2010 1:57 am

Eg.407
4*4*4=64
0*0*0=0
7*7*7=343 now 64+0+343=407.
Any number which satisfies the above condition is called as Armstrong

class Armstrong
{
    public static void main(String[] args)
       {
          int num=Integer.parseInt(args[0]);
          int rem,sum=0,no;
          no=num;
          while(no!=0)
            {
               rem=no%10;
               sum+=rem*rem*rem;
               no/=10;      
            }
          if(sum==num)
              System.out.println(num+" is an Armstrong number");
          else
              System.out.println(num+" is not an Armstrong number");    
       } 
}

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: