The first known prime found to exceed one million digits was
discovered in , and is a
Mersenne prime of the form ; it contains exactly digits. Subsequently other
Mersenne primes, of the form ,
have been found which contain more digits.
However, in there was found
a massive non-Mersenne prime which contains digits: .
Find the last ten digits of this prime number.
解决方案
使用 python 中的 pow 直接计算。
代码
1 2 3 4 5
a = 7830457 b = 28433 mod = 10 ** 10 ans = (pow(2, a, mod) * b + 1) % mod print("{:010}".format(ans))