the factorizations come fromm doing polynomial long division of x^n-1 and x^n+1 with x^p-1 and x^p+1 if n=pq
x^n-1 = (x^p-1)(x^{p(q-1)}+x^{p(q-2)}+\cdots +x^p+1)
The other equation should read:
x^n+1 = (x^p+1)(x^{p(q-1)}-x^{p(q-2)}+\cdots -x^p+1 )
With alternating signs...