Its sowing the wrong out put

please help me with this

@chemant077 this is the correct by method which you are using to find inverse (https://ide.codingblocks.com/s/201296)

https://ide.codingblocks.com/s/201288 whats problem with my this updated code??

please explain your logic as in videos also it given the ame approach as i have done

@chemant077 your updated code is correct but you have to use long long int since you are calculating pow(n,1000000005).