Example: 5x2 + 7x + 2
Step one : Factor the first and the last coefficients (into prime factors). In
the above
example first coefficient is 5 and the last coefficient is 2
Step two : Make a big X and put the factors for each coefficient across the X.

Step 3: Multiply two numbers at a time (any way in the X)
to get two pairs of numbers
that add / subtract to give the middle coefficient (here 7.)
Correct way: 5.1 = 5 and 2.1 = 2
And 5 +2 = 7
Incorrect way: 5.2 =10 and 1.1= 1
And 
Step 4: Factor by grouping :
5x2 + +5x + 2x + 2 (Using 5x +2x = 7x)
5x(x+1) +2(x+1)
(5x+2) (x+1)