What is wrong in my code?

Hey @mayanktyagi
Don’t use the pow function because it can lead to overflow so instead calculate power using a loop and if it exceeds n then break.

My code is working fine for some input but not for others, why?

Hey @mayanktyagi

read the comments

pls explain the thing about power function and how to implement it correctly

Hey @mayanktyagi
10^8 now if u try to compute power(10^8,10) then this will lead to overflow

Here see this code https://ide.codingblocks.com/s/390007 to correctly impelemnt it