You are viewing a single comment's thread. Return to all comments →
In the editorial, I am unable to understant the part where inverse of n is being calculated.
Precisely, this part =>
for i in xrange(2,p): inv[i] = (p - p/i) * inv[p%i] % p
I know how to calculate inverse using extended Euler's theorem. It would be nice if you could elaborate the logic behind it or share some link.
Seems like cookies are disabled on this browser, please enable them to open this website
An unexpected error occurred. Please try reloading the page. If problem persists, please contact support@hackerrank.com
Ajob Subsequence
You are viewing a single comment's thread. Return to all comments →
In the editorial, I am unable to understant the part where inverse of n is being calculated.
Precisely, this part =>
calculate inverses mod p
for i in xrange(2,p): inv[i] = (p - p/i) * inv[p%i] % p
I know how to calculate inverse using extended Euler's theorem. It would be nice if you could elaborate the logic behind it or share some link.