Doubt in my code

Here is my code :

When I give input as 1634 it throws me output as :

10080140

Why it is happening?
What is the problem with my code?

Hey @yashsharma4304 the code you have written is not the right implementation of the problem. You have to change your approach to solve this question.

But what is the problem in this implementation ?
Where I am going wrong?

Firstly you are using 2 while loop, which is not required to calculateArmstrong of a given number, after that the way you are calculating Armstrong is wrong. At last you have to print true or false, but you are printing a number which is wrong.

1 Like

Ok. I understand my mistake

Here is my code. Now it is giving me the correct output. But can you tell me any different approach.

Yeah I know that I have to print true or false but I was just playing with the code :sweat_smile:

Now your implementation works fine, it’s good that you are knowing your own implementation by playing with your code and I appreciate that. Moreover if you still want to know more about Armstrong numbers you can refer it from here: https://www.geeksforgeeks.org/program-for-armstrong-numbers/

1 Like

Ok thank you for helping me. :relaxed: