1 | initial version |
The size of powers grows exponentially, so before computing it's worth checking whether it'd be possible to accommodate the result in memory.
As for your specific powers p**e - 1
, you can compute first f**(p**e)
by iterative raising to power p
, and then divide the result by f
:
f = X**7 + Y**5
g = f
for e in range(1, 10):
g **= p
print( e, g//f )
However, be prepared that this computation will die after first few values due to enormous and ever growing size of the result.