How does $n^4 + 6n^3 + 11n^2 + 6n + 1 = (n^2 + 3n + 1)^2?$ C++ student here, not quite familiar with these type of expressions. Can someone explain how does this work? I'm familiar with $(a+b)^2$ etc. mathematics but this seems to be like $(a+b+c)^2$ and having searched online, the opened form for this formula doesn't look much alike. Any help will be appreciated. Thanks!

When you expand something squared, you multiply each term by each other term, so in this case you have $$\begin{aligned}(n^2+3n+1)^2&=n^2\cdot n^2 + n^2\cdot 3n+n^2\cdot 1\\&\;+3n\cdot n^2+3n\cdot3n+3n\cdot1\\&\;+1\cdot n^2+1\cdot3n+1\cdot1\\&=n^4+3n^3+n^2+3n^3+9n^2+3n+n^2+3n+1\\&=n^4+6n^3+11n^2+6n+1\end{aligned}$$
