I suddenly came across these lines of code when looking at others' submissions: (M is a prime)
inv=1; for(i=2;i<N;i++) inv[i]=(M-M/i)*inv[M%i]%M;
I tried to google it to understand the formula but ended up finding nothing. So could anyone give me the proof for this?
Thanks a lot <3 <3.