Calculate power of irrational number modulo of integer

657 Views Asked by At

There are very efficient ways to calculate powers of integers modulo an integer, one of them is implemented by the Python pow function.

I need to calculate something of the form floor(num^k) % n where num is irrational and k, n are integers.

For example how can I calculate the exact value floor(π^k) % n without actually calculating the huge value of π^k?

Thank you all brilliant people.

1

There are 1 best solutions below

0
On

The only way I know of to speed up exponentiation modulo an integer $n$ (compared to general exponentiation) is using the fact that everything is integers to reduce the intermediate results modulo $n$. As the intermediate results in your case aren't integers, you can't do that.

The only transformation I can see of your expression is: $$ \left\lfloor x^k\right\rfloor \pmod n =\left\lfloor x^k\pmod n\right\rfloor $$ and that doesn't make the computation any easier.