# Factoring polynomials over IntegerModRings

I'd like to factor efficiently polynomials over rings (more particularly the rings of the form IntegerModRing(n), other rings don't interest me right now). I've noticed that you can factor a polynomial differently when considering FIELDS, so that something like

factor(x^2-2, QQ[]) factor(x^2-2, RR[])

will output the different expected results. But what about

x = var('x') factor(x^5-x, IntegerModRing(25)['x'])?

What is actually outputted right now is

(x-1)*(x+1)*(x^2+1)*x

but the true factorization is
x*(x-1)*(x+1)*(x-7)*(x+7)

(I computed it by hand, Sage couldn't do it.) Going for small numbers like 25 is easy but when I go for large numbers I get nasty codes if I try to compute that myself. Isn't there anyway to make the factor command factor those polynomials or another way to do it? Any suggestion is welcome.

I am new to Sage and I am beginning to love its features since I begin to study number theory and Sage has plenty of options for that purpose, but I must admit they are quite hard to understand since I am also new to Python, PARI, Magma... (not to programming though!) explanations in detail would be deeply appreciated.

Probably related: http://math.stackexchange.com/questio...