An Armstrong
number is an n-digit number that is equal to the sum of the nth powers of its digits.
For example 153 is an Armstrong Number in 3 digit number
13 + 53 + 33 = 153
1 +125+27 =153
1634 is an Armstrong Number in 4 digit number
14 + 64 + 34 + 44 = 1634
1+1296+81+256=1634
And so numbers from 0-9 all are Armstrong
Numbers
as 01 is 0 , 11 is 1, 21 is 2 , 31 is 3
and so on..
ARMSTRONG Flowchart
Armstrong
Algorithm
Step1: Read a number.
Step2: Store
all the digits of a number in an array digits[]
Step3:
Count all the digits of a number and store in variable length
Step4:
Start a loop till the length of a
number
Step5: Raise each digit to a power equal to the
number of digits in the number. For ex, each digit of a three‑digit
number
would be raised to the third
power;
each digit of a Seven‑digit
number
would be raised to the Seventh
power; and
so on
Step6: Add the results to variable sum
Step7: Now check if number
is equal to sum.
Step8:If the condition is true then
display “It is an Armstrong Number’’ Else display “It is not an Armstrong
Number”.
Step9: Stop
ARMSTRONG Flowchart
Comments
Post a Comment