Armstrong number from 100 to 500
class
Arm_range
{
public static void main(String[] args)
{
int temp,r,sum;
for(int i=100; i<=500; i++) {
temp = i;
sum = 0;
while(temp!=0) {
r = temp%10;
sum = sum+(r*r*r);
temp = temp/10;
}
if(sum ==i) {
System.out.print(i+" ");
} } } }
No comments:
Post a Comment