You are viewing a single comment's thread. Return to all comments →
It may help for people who are using c/c++ or don't want to use any BigInt type libraries (i.e. if you are a performance freak).
using ull = unsigned long long; constexpr ull Modulus = 10000000000ULL; inline ull modMul(const ull x, const ull y) { if (x > (1<<30) && y > (1 << 30)) return ((x >> 30)*((y << 30) % Modulus) + y*(x & ((1 << 30) - 1))) % Modulus; ull z = x*y; if (z >= Modulus) z %= Modulus; return z; }
Seems like cookies are disabled on this browser, please enable them to open this website
Project Euler #48: Self powers
You are viewing a single comment's thread. Return to all comments →
It may help for people who are using c/c++ or don't want to use any BigInt type libraries (i.e. if you are a performance freak).