It shows the number itself as output


Unable to debug the code

@tanjuljain19 The problem is you are initializing x=n-1, but at the above step when filling the initial array, you have n=0.
So just store the n in some temp variable and use that.

I hope you got the mistake now, feel free to ask.
Otherwise please mark it as resolved.

Thanks a lot for help

1 Like