I want to execute this math function:
3^(3^1000000000) mod 1000000007
the result of this is: 930782551
But do it directly in python takes a huge amount of time, and the program hangs:
return pow(3,pow(3,1000000000),1000000007)
So I thought that execute this will be the same:
return pow(3,pow(3,1000000000, 1000000007),1000000007)
but the result is: 270196661
How can I get the correct result 930782551
in a reasonable time?