Expand (1+x+x2)3 using binomial expansion.
Put 1 + x = y. then,
(1+x+x2)3=(y+x2)3
=3C0y3+3c1y2x2+C2y(x2)2+3C3(x2)3=y3+3y2x2+3yx4+x6=(1+x)3+3x2(1+x)2+3x4(1+x)+x6=(1+3C1x+3C2x2+3C3x3)+3x2(1+2x+x2)+3x4(1+x)+x6=(1+3x+3x2+x3)+(3x2+6x3+3x4)+(3x4+3x5)+x6=x6+3x5+6x4+7x3+6x2+3x+1.Hence(1+x+x2)3=x6+3x5+6x4+7x3+6x2+3x+1.