import java.util.*;
public class Ch2Q26
{
public static void main(String[] args)
{Scanner kbd = new Scanner(System.in);
System.out.print("Enter an integer: ");
int no = kbd.nextInt();
if(amg(no))
System.out.println("Armstrong No");
else System.out.println("Not an Armstrong No");
}
static boolean amg(int no)
{int no1 = no;
int sum = 0;
while(no != 0)
{ int dig = no % 10;
no /= 10;
sum += Math.pow(dig, 3);
}
return (sum == no1);
}
}
No comments:
Post a Comment