import java.util.*;
class Armstrong{
private static Scanner s;
public static void main(String[] args) {
s = new Scanner (System.in);
int c=0,a,temp;
System.out.println("enter some number");
int n=s.nextInt();
temp=n;
while(n>0)
{
a=n%10;
n=n/10;
c=c+(a*a*a);
}
if(temp==c)
System.out.println("armstrong number");
else
System.out.println("Not armstrong number");
}
}
class Armstrong{
private static Scanner s;
public static void main(String[] args) {
s = new Scanner (System.in);
int c=0,a,temp;
System.out.println("enter some number");
int n=s.nextInt();
temp=n;
while(n>0)
{
a=n%10;
n=n/10;
c=c+(a*a*a);
}
if(temp==c)
System.out.println("armstrong number");
else
System.out.println("Not armstrong number");
}
}
No comments:
Post a Comment