If I have a polynomial:
$$f(x) = c_0 x^0 + c_1 x^1 + c_2 x^2 + \dots + c_n x^n$$
How can I find the polynomial, modulo a prime number $p$? In other words, I want to take all of the coefficients modulo $p$, and all of the powers modulo $p-1$. So, for instance, the result modulo 3 would be:
$$(c_0 \bmod 3)x^0+$$ $$(c_1 \bmod 3)x^1+$$ $$(c_2 \bmod 3)x^0+$$ $$(c_3 \bmod 3)x^1+$$ $$(c_4 \bmod 3)x^0+$$ $$(c_5 \bmod 3)x^1+$$ $$\dots$$
Please note that this is just an example, and in general I want to find any polynomial modulo any prime $p$.
So, in general, I have something like:
5 + 13x + 14x^2 + 7x^3 + 8x^4
I want to take all powers of $x$ modulo $p-1$, so I get:
5 + 13x + 14 + 7x + 8
...which, in turn, equals, by simplifying:
27 + 20x
Then, taking all coefficients modulo 3, we get:
0 + 2x
How can I code this?