a^5-a^4+a^2+1
=a^5-a^3-a^4+a^2+a^3+1
=a^3(a^2-1)-a^2(a^2-1)+(a^3+1)
=a^3(a+1)(a-1)-a^2(a+1)(a-1)+(a+1)(a^2-a+1)
=(a+1)[a^3(a-1)-a^2(a-1)+a^2-a+1]
=(a+1)(a^4-a^3-a^3+a^2+a^2-a+1)
=(a+1)(a^4-2a^3+2a^2-a+1)
a^5-a^4+a^2+1
=a^5-a^3-a^4+a^2+a^3+1
=a^3(a^2-1)-a^2(a^2-1)+(a^3+1)
=a^3(a+1)(a-1)-a^2(a+1)(a-1)+(a+1)(a^2-a+1)
=(a+1)[a^3(a-1)-a^2(a-1)+a^2-a+1]
=(a+1)(a^4-a^3-a^3+a^2+a^2-a+1)
=(a+1)(a^4-2a^3+2a^2-a+1)