Ask Your Question

# Revision history [back]

### Power of a polynomial mod (n, X^r - 1)

I need to calculate (X + a)^n mod (n, X^r - 1), where n can be very large.

I use the following code:

R.<x>=PolynomialRing(Integers(n)) pow(x + a, n, X^r - 1)

A better (i.e. faster) solution?

Thanks.

 2 retagged vdelecroix 7157 ●16 ●78 ●156 http://www.labri.fr/pe...

### Power of a polynomial mod (n, X^r - 1)

I need to calculate (X + a)^n mod (n, X^r - 1), where n can be very large.

I use the following code:

R.<x>=PolynomialRing(Integers(n)) pow(x + a, n, X^r - 1)

A better (i.e. faster) solution?

Thanks.