\(a^8+a^4+1=\left(a^8+2a^4+1\right)-a^4\)
\(=\left(a^4+1\right)^2-a^4\)
\(=\left(a^4-a^2+1\right)\left(a^4+a^2+1\right)\)
\(=\left[\left(a^4-2a^2+1\right)-a^2\right]\left(a^4+a^2+1\right)\)
\(=\left[\left(a^2-1\right)^2-a^2\right]\left(a^4+a^2+1\right)\)
\(=\left(a^2-a-1\right)\left(a^2-a+1\right)\left(a^4+a^2+1\right)\)
*\(a^8+a^7+1=a^8+a^7+a^6-a^6+a^5-a^5+a^4-a^4+a^3-a^3+a^2-a^2+a-a+1\)\(=\left(a^8+a^7+a^6\right)+\left(a^5+a^4+a^3\right)+\left(a^2+a+1\right)-\left(a^6+a^5+a^4\right)-\left(a^3+a^2+a\right)\)\(=a^6\left(a^2+a+1\right)+a^3\left(a^2+a+1\right)+\left(a^2+a+1\right)-a^4\left(a^2+a+1\right)-a\left(a^2+a+1\right)\)\(=\left(a^2+a+1\right)\left(a^6-a^4+a^3-a+1\right)\)