We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
Little fermat's theorem applies:
a^p = a (mod p),
where p is prime number, a in Z and is not divided by p.
so you can divide by a.
division by a^2 gives you: a^(p-2) = a^-1 (mod p)
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Sherlock and Permutations
You are viewing a single comment's thread. Return to all comments →
Little fermat's theorem applies: a^p = a (mod p), where p is prime number, a in Z and is not divided by p. so you can divide by a. division by a^2 gives you: a^(p-2) = a^-1 (mod p)