I failed two test cases could u help me to in solving this problem

i failed two test cases could u help me in correcting this code.

Hello, pls read the ques carefully why are you doing rrr everytime it is like you are considering a no. is armstrong no. when the cube of its digits is equal to the no. itself.

while(n>0 && n<1000000000) {
	r=n%10;
	p=p+r*r*r;
	n=n/10;
}

You need to count the digits of the no. first of all then try that power of that digit to every digit and sum that. And after that you need to check if that sum is equal to the no. itself.
As given in the explanation.
abcd… = pow(a,n) + pow(b,n) + pow(c,n) + pow(d,n) + ….

1634 is an Armstrong number as 1634 = 1^4 + 6^4 + 3^4 + 4^4

371 is an Armstrong number as 371 = 3^3 + 7^3 + 1^3

In 1634 we have taken the power 4 as the total digits of the nos. is 4.

I hope it is clear to you. In case it is clear to you pls mark it as resolve and provide the rating as well as feedback so that we can improve ourselves.
In case there is still some confusion pls let me know, I will surely try to help you out.
Thanks :slight_smile:
Happy Coding !!

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.