Java program to check if a number is armstrong or Not

Similar Question:

     Print List of Armstrong number.


Solution:


class armstrong
{
public static void main(String args[])
{
int s=0,n=153,m,d;
m=n;
while(n>0)

{
d=n%10;
s=s+(d*d*d);
n=n/10;
}
if(m==s)
System.out.println("number is armstrong");
else
System.out.println("number is not armstrong");
}
}


Comments

Popular posts from this blog

Today Walkin 14th-Sept

Hibernate Search - Elasticsearch with JSON manipulation

Spring Elasticsearch Operations