Where did I go wrong in this code?

ake the following as input. A number Write a function which returns true if the number is an armstrong number and false otherwise, where Armstrong number is defined as follows. A positive integer of n digits is called an Armstrong number of order n (order is number of digits) if. abcd… = pow(a,n) + pow(b,n) + pow(c,n) + pow(d,n) + ….

don’t return true/false print it there

Also 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 !!

It’s working but returning 0 and 1 instead of true or false

add the “” make it “true” and “false”

Test cases 0 and 1 still fail. Rest all pass (there are 6)

yes you need to correct this, your code says false for 1634

So I need to completely change my code?

Can you suggest any changes in the IDE itself?

sure


Here did the required changes in your code :slight_smile:
If this resolves your query then please mark it as resolved:)

1 Like