How to make sure that I actually proved a theorem, when a result seems to be correct? I've started to learn math not that long ago, what I actually must have been doing at school, but never mind.
Solving exercises, I ask myself pretty often, if I'm right making my final conclusions, proving a theorem. Of course, I haven't faced yet with something really hard to solve. Currently I'm not gonna ask about proofs for any type of exercises, but rather about my specific case I've faced with.
Just today I solved the next exercise:

Prove that for any natural value of "n"(not equal to 1), the result of the expression $(n^4 + n^2 + 1)$ is a composite number.

Not without help, but I solved it, getting the next result $$(n^2 + n + 1)(n^2 - n + 1)$$

And here is the point. I've proved it just by substituting several random numbers in the place of "n" variable, getting the right result. And this seems to be such a lame and a wrong approach, because there are ∞ numbers, when I've tried just 3-5 of them. And that's it.

How can I make sure that my proofs are right, not by substituting numbers and not by making something unreliable like substituting, but by... I don't know even by why. I'm confused about that.

I hope you can advise me something and give me some tips, maybe explanations, because possibly I'm wrong or just don't understand something important. What do you think ?
 A: Proof making is a constructive process: in every new proof you use properties you proved before and combine them in a very clear way.
In this case you need two preceding facts

*

*$(a+b)(a-b) = a^2 - b^2$

*$(a + b)^2 = a^2 + 2ab + b^2$
which in turn are derived from more basic ones, as I will indicate below.
To illustrate the process I will go through it in a rather lengthy development. Note however that you should proceed incrementally, starting from very simple equations and progressing toward more complex ones, step by step, in separate exercises.
For the first property:
\begin{align*}
   (a+b)(a-b) &= a(a-b) + b(a-b)          &&\textrm{; distrib.}\\
        &= (a^2 + a(-b)) + (ba + b(-b))   &&\textrm{; distrib.}\\
        &= a^2 + (a(-b) + ba) + b(-b))       &&\textrm{; assoc. (twice)}\\
        &= a^2 + (a(-b) + ab) + b(-b))         &&\textrm{; commut.}\\
        &= a^2 + (a(-b + b)) + b(-b))     &&\textrm{; distrib.}\\
        &= a^2 + (a0 + b(-b))              &&\textrm{; add. inv.}\\
        &= a^2 + (0 + b(-b))               &&\textrm{; zero mult.}\\
        &= a^2 + b(-b)                     &&\textrm{; zero sum}\\
        &= a^2 - b^2                       &&\textrm{; add. inv. mult.}
\end{align*}
Note that you should know why each of the justifications on the right end holds. If not, step back and prove them.
The second equation follows similarly so I will leave it to you as an exercise.
Now the property you are interested in:
\begin{align*}
   (n^2 + n + 1)(n^2 - n + 1) &= ((n^2 + 1) + n)((n^2 + 1) - n)
                                   &&\textrm{; commut. + assoc.}\\
         &= (n^2+1)^2 - n^2        &&\textrm{; fact 1 above}\\
         &= (n^2)^2 + 2n^2+1 - n^2 &&\textrm{; fact 2 above}\\
         &= n^4 + 2n^2 - n^2 + 1   &&\textrm{; commut.}\\
         &= n^4 + n^2 + 1.
\end{align*}
So far we have proven
$$
    n^4 + n^2 + 1 = (n^2+n+1)(n^2-n+1).
$$
However, this does not automatically imply that this is a composite number. We first need to show that $n^2+n+1>1$ and $n^2-n+1>1$, provided that $n>1$. So, we have to deduce these inequalities:
\begin{align*}
    n^2+n+1 &> n^2 - n + 1          &&\textrm{; $n > -n$}\\
         &= n(n-1) + 1              &&\textrm{; distrib.}\\
         &\ge n1 + 1
            &&\textrm{; $n>1\Rightarrow n-1>0\Rightarrow n-1\ge1$}\\
         &= n + 1                   &&\textrm{; $1$ mult.}\\
         &> 1 + 1                   &&\textrm{; $n>1$}\\
         &> 1.                      &&\textrm{; $1>0$}
\end{align*}
