Please,solve my doubt.2 test cases are getting failed.
Is Armstrong Number
Hello @Gade_Deepthi,
The problem is in the following logic that you have applied:
val=val+(rrr);
- Determine how many digits are in the number. Call that n.
- Then take every digit in the number and raise it to the n power.
- Add all those together, and if your answer is the original number then it is an Armstrong number.
All single digit numbers are Armstrong numbers. For example, test 6. One digit. 6^1 = 6. Armstrong number.
Test 371. Three digits. 3^3 + 7^3 + 1^3 = 27 + 343 + 1 = 371. Armstrong number.
Test 1634. Four digits. 1^4 + 6^4 + 3^4 + 4^4 = 1 + 1296 + 81 + 256 = 1634. Armstrong number.
There are no 2-digit Armstrong numbers.
There are four 3-digit Armstrong numbers.
There are two 4-digit Armstrong numbers.
Hope, this would help.
Give a like if you are satisfied.
I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.
On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.