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
Armstrong Numbers
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");
}
}
Taywin 312 Posting Virtuoso
javalover -4 Newbie Poster
Taywin 312 Posting Virtuoso
Nutster 58 Newbie Poster
vinnitro 12 Newbie Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.