Click Here To Follow our Telegram Channel for more such news and amazing free stuffs.

  Telegram Channel  - https://t.me/codexelltech


    import java.util.Scanner;
    public class ArmStrong
 

    {
       public static void main(String[] args)
        {
            int n, count = 0, a, b, c, sum = 0;
            Scanner s = new Scanner(System.in);
            System.out.print("Enter any integer you want to check:");
            n = s.nextInt();
            a = n;
            c = n;
            while(a > 0)
            {
               a = a / 10;
               count++;
            }
             while(n > 0)
            {
             b = n % 10;
             sum = (int) (sum+Math.pow(b, count));
             n = n / 10;
            }
           if(sum == c)
            {
             System.out.println("Given number is Armstrong");
            }
            else
            {
            System.out.println("Given number is not Armstrong");
            }   
          }
        }


Output:
Enter any integer you want to check:153
Given number is Armstrong 

Click Here To Follow our Telegram Channel for more such news and amazing free stuffs.

  Telegram Channel  - https://t.me/codexelltech

Click here to visit www.codexell.tech for more such references. 

Previous Post Next Post