def powmod(x, y, z): ybi = [] while y != 0: ybi.append(y % 2) y /= 2 out = 1 ybi.reverse() for i in ybi: out = out * out % z if i == 1: out = out * x % z return out a = powmod(2, 7830457, 100000000000) b = a * 28433 + 1 b %= 10000000000 print b