Virat and ncr wa pls help

sir i think my code is right pls tell why test cases are not passing link to code is
https://ide.codingblocks.com/s/145072 pls optimise my code

Use fermet’s little theoram here.
You can store factorials upto n, use them to calculate inverse.
Note: Use modula while calculating factorial and then take inverse.
It would be a small and easy code for you :slight_smile:

but fermat theorem states tht if p is prime the (a^p-p) is multiple of p how to use it
in calculating ncr moreover i think iam calculating mod of factorial once,factorials are stored in vector forms pls take a look at the code and highlight my mistakes and optimise it so that i get better knowledge of ques ???can you do a vedio call or simple call ?? pls do reply fast

is my method to calculate inverse correct??

Okay ,Let’s discuss this in inbox