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.
Also 10^9+7 is prime, which means we can make use of Fermat's little theorem. It is essential for this question, for example in python: doing pow(x, y, z) as opposed to x**y % z is much more efficient because it takes advantage of Fermat's little theorem.
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Shashank and List
You are viewing a single comment's thread. Return to all comments →
Also 10^9+7 is prime, which means we can make use of Fermat's little theorem. It is essential for this question, for example in python: doing pow(x, y, z) as opposed to x**y % z is much more efficient because it takes advantage of Fermat's little theorem.