#include #include __uint128_t modulo = 162236438017UL; __uint128_t n = 956UL; __uint128_t initpow10 = 1000UL; /* __uint128_t modulo = 4461161689UL; __uint128_t n = 923UL; __uint128_t initpow10 = 1000UL; */ /* uint64_t modulo = 259110739UL; uint64_t n = 98UL; uint64_t initpow10 = 100UL; */ /* uint64_t modulo = 1436994233UL; uint64_t n = 416UL; uint64_t initpow10 = 1000UL; */ /* uint64_t modulo = 78317; uint64_t n = 39UL; uint64_t initpow10 = 100UL; */ int main() { __uint128_t x = n; __uint128_t pow10 = initpow10; while (x < (modulo-1UL)) { x++; if (x == pow10) { pow10 *= 10; } n = (pow10*n + x) % modulo; if ((x & 1073741823UL) == 0) { printf("%lu\n", (unsigned long)x); } } printf ("%lu\n", (unsigned long)n); }