25) C PROGRAM TO CHECK WHETHER THE NUMBER IS ARMSTRONG NUMBER OR NOT
LOGIC:- Let there is a number of n digits .If the sum of each (digits * n times of that digits) is equal to the number of n digits.Then the number is palindrome.
In the case of three digits for example:- 153 (3 digits number) = 1(digit one) * 1 *1(3 times multiply) + 5*5*5 + 3*3*3 will become 153 which is the actual number, so 153 is armstrong number.
Logic is applied as we applied in finding the reverse of the number.
EXAMPLE:-
LOGIC:- Let there is a number of n digits .If the sum of each (digits * n times of that digits) is equal to the number of n digits.Then the number is palindrome.
In the case of three digits for example:- 153 (3 digits number) = 1(digit one) * 1 *1(3 times multiply) + 5*5*5 + 3*3*3 will become 153 which is the actual number, so 153 is armstrong number.
Logic is applied as we applied in finding the reverse of the number.
EXAMPLE:-
EXAMPLE:- THIS IS VALID ONLY FOR 3-DIGIT NUMBER RANGE
TASK"""TRY TO FIND ARMSTRONG NUMBER IN ANY RANGE"""
Comments
Post a Comment