check the number is Amstrong (using java)


// if the addition of cube of all the digit of a number is same as original number 

ex- 153  1^3+5^3+3^3=153

 class amstrong

{

public static void main(String args[])

{

int  no=125, sum=0,copy=0,b=0;

while(no>0)

{

b=n0%10;

no=no/10;

sum=sum+b * b * b;

}

if(copy= =sum)

System.out.println("amstrong number");

else

System.out.println("not amstrong");

}

}

Comments

Popular posts from this blog