Armsrong Number:-

The armstrong number is a number that is equal in sum of own digit number raisid to the power of number in digit . then it is a armstrong number .

*Example: *

For a 3-digit number, if the sum of each digit raised to the power of 3 is equal to the original number, then it is an Armstrong number.

For instance:

153 is an Armstrong number because:

no = 153
rem = no % 10
(1*1*1)(5*5*5)(3*3*3)
=1+125+27
=153

*For example: *

$ Following the method.
$ first of look the board start

Image description

step by step explain:

step 1:-
No = 153
Arm = 0
Rem = No % 10
Arm = Arm + (Rem*Rem*Rem)
=0+(3*3*3)
=> 27 -------------------> Arm
No = No/10
=153/10
=>15

step 2:-
No = 15
Arm = 27
Rem = No % 10
Arm = Arm + (Rem*Rem*Rem)
=27+(5*5*5)
=> 152 -------------------> Arm
No = No/10
=15/10
=>1

step 3:-
No = 1
Arm = 152
Rem = No % 10
Arm = Arm + (Rem*Rem*Rem)
=152+(1*1*1)
=> 153 -------------------> Arm
No = No/10
=1/10
=0

no>0 -----> condition false loop stop.

Armstrang:

Image description

Explanation Line by Line:

  1. int number = 153;
    $ You want to check whether 153 is an Armstrong number.

  2. int originalNumber = number;
    $ Save the original number so that you can compare it later.

  3. int Armstrang = 0;
    $ A variable to store the sum of cubes of the digits.

Repeat until number becomes 0.
So for 153:

→ 3³ + 5³ + 1³ = 27 + 125 + 1 = 153

If-Else Condition:

if(originalNumber == Armstrang)

If the result is same as original number → Armstrong

Else → Not Armstrong

Output:
153 this armstrong