how do you factor $x^2 +kx+40$ over the integer please please help me, I'm having a lot of troubles. I tried to use a^2+2ab+b^2 formula (like i was told) but that's where  get lost. I understand that Factoring uses the opposite operation, but 40 cannot be square rooted. 
 A: Hint.  If we have an integer factorisation
$$x^2+kx+40=(x-a)(x-b)$$
then
$$ab=40\quad\hbox{and}\quad -a-b=k\ .$$
Can you use the first equation to find some (or all) possible values of $a,b$?  Then substitute into the second equation to find possible values of $k$.
A: When solving problems like this, I often use factoring by decomposition. We have our expression:
$$x^2+kx+40$$
Now, $1\times 40=40$. We now need to find two factors of $40$ that add up to $k$. In this case, there are a lot of possibilities. The first two factors that pop up in my mind are $4$ and $10$. This adds up to $14$, therefore one of the solutions is $k=14$. Try other factors, e.g. $5$ and $8$. This adds up to $13$, therefore another solution is $k=13$. Yet another solution is $k=-22$ (factors: $-20$ and $-2$).
Don't believe me? Try to factor these expressions:
$$x^2+41x+40$$
$$x^2-41x+40$$
$$x^2+22x+40$$
$$x^2-22x+40$$
$$x^2+14x+40$$
$$x^2-14x+40$$
$$x^2+13x+40$$
$$x^2-13x+40$$
Prepare to be amazed :-)

Answers to above expressions I told you to try to factor:
$$x^2+41x+40=(x+1)(x+40)$$
$$x^2-41x+40=(x-40)(x-1)$$
$$x^2+22x+40=(x+20)(x+2)$$
$$x^2-22x+40=(x-20)(x-2)$$
$$x^2+14x+40=(x+4)(x+10)$$
$$x^2-14x+40=(x-4)(x-10)$$
$$x^2+13x+40=(x+5)(x+8)$$
$$x^2-13x+40=(x-5)(x-8)$$
A: If we look at the determinant
$$D=k^2-160$$
we see that to get an integer solution, $D=q^2$ (some $q$). Moreover, both $k-q$ and $k+q$ must be divisible by $2$ (solutions: $x_{1,2}=\frac{-k\pm \sqrt{D}}{2}$).
Thus, $$k^2-q^2=160$$
$$(k-q)(k+q)=160$$
The only ways how $160$ may be factorized by even numbers are: $2*80,4*40, 8*20, 10*16$. Therefore, e.g., $$k-q=2$$ $$k+q=80$$ $\Rightarrow$ $k=41$, the others $k=13,14,22$ follows in the same way.
E.g. for $k=13$, $x_{1,2} = \frac{-13\pm 3}{2} = \{-8,-5\}$. To get positive integer solutions, we just take the negative $k=-13,-14,-22,-41$.
EDIT: Taking factorization $5*32=160$ there is yet another integer solution for $k=\pm18.5$, $x=\mp 16$.
