Help me with this code!

https://www.codechef.com/viewsolution/42988065

Firstly, if sum<=a you are printing twice the output. Secondly, i don’t think your logic will give correct answer.