Based on cpp.sh, it is correct?
What do you mean "lesser by 1"? Like 5^3 to 6^3 is 340? I ran it and it computes 341.
Last edited on
Your code worked for me. I used 6, 7, 8, 9, and 10 for N and it was right every time.
Last edited on
Thats weird, it comes out as incorrect for me.
I just tried 6 and 7 and 10, and the output is always 1 less than the correct answer i.e. If I enter a 7, output is 683 when it should be 684.
Why are you guys getting the correct answer and im not?
I just ran it in the cpp shell. Its works fine there.
However, if I run it in my codeblocks compiler, I always get an output 1 less than the correct answer.
Any idea why this is happening?
I have no idea. I ran it visual studio and it worked fine.
What editor and compiler are you using?
Last edited on