Here is an example that uses SymPy to factor polynomials.
from ipywidgets import interact
from sympy import Symbol, Eq, factor
x = Symbol('x')
def factorit(n):
return Eq(x**n-1, factor(x**n-1))
factorit(12)
x**12 - 1 == (x - 1)*(x + 1)*(x**2 + 1)*(x**2 - x + 1)*(x**2 + x + 1)*(x**4 - x**2 + 1)
interact(factorit, n=(2,40));
x**21 - 1 == (x - 1)*(x**2 + x + 1)*(x**6 + x**5 + x**4 + x**3 + x**2 + x + 1)*(x**12 - x**11 + x**9 - x**8 + x**6 - x**4 + x**3 - x + 1)