Armstrong number n digit
Checking for armstrong number which can be even more than 3 digit.
Source Code
Run Output
Code Understanding
while (n1 != 0){n1 /= 10;++digits;}
This portion of code helps to find number of digits in the given number.
num+=pow(rem,digits);
This line helps to provide exponentiation of individual digit to total number of digits.
most other portion of the code is same as given for finding a 3 digit armstrong number.
Notes
Please do not use an input number more than 11 digit, so that correctness of result can be ensured.
Suggested Filename(s): armstrong-n.cpp
Created: 2-Dec-2017 14:56 | Updated: 15-Sep-2018 13:49|
