import java.util.*; public class Main { public static void main(String[] args) { int n, arg, sum = 0, r; Scanner s=new Scanner(System.in); System.out.println("Enter a number: "); n=s.nextInt(); // input value arg = n; for (int i = 1; i < n; i++) { while (n > 0) { r = n % 10; sum = sum + (r * r * r); n = n / 10; } } if (arg == sum) { System.out.println("Given number is armstrong number: " + arg); } else { System.out.println("Given number is not armstrong number: " + arg); } } }
Enter a number: 153
Given number is armstrong number: 153