How do you factor when a is not 1?
Answer
To factor a polynomial you must reduce the polynomial expression to its factors.
We are going to use a method known as the 'ac' method to factor by grouping. Many people do not realize that there is actually a systematic way to factor by grouping. This is the closes thing to a 'formula' that you will find for factoring by grouping. It is always much easier to look at some example problems before reading generalized steps, but the steps go as follows
Formula for Factoring By Grouping
If you have a quadratic equation in the form $$ \color{Red}{a}x^2 + \color{purple}{b}x + \color{Yellow}{c} $$
 Step 1) Determine the product of AC (the coefficients in a quadratic equation)
 Step 2) Determine what factors of $$ \color{Red}{a} \cdot \color{Yellow}{c} $$ sum to $$ \color{purple}{b}$$
 Step 3) "ungroup" the middle term to become the sum of the factors found in step 2
 Step 4) group the pairs.
As I expressed earlier, it's much easier to understand this method by simply walking through a few examples. So don't worry if the steps above seem like algebraic nonsense  just check out the example problems below.
Practice Problems
Use the formula
Product of (a)(c) = (5)(9) = 45
What factors of 45 sum to 18?
3 & 15
Think of 18x as 3x + 15x
5x² + 3x + 15x + 9
Group the 2 pairs: (5x² + 3x) + (15x + 9)
Remove the common factors: $$ x \color{Red}{(5x + 3)} + 3 \color{Red}{(5x + 3)} $$
Rewrite as grouped factors: $$(x + 3) \color{Red}{(5x + 3)}$$
You know the deal Use our formula for factoring by grouping
Product of (a)(c) = (7)(2) = 14
What factors of 14 add up to to 9?
7 & 2
Think of 9x as 7x + 2x
7x² + 7x + 2x + 2
Group the 2 pairs : (7x² + 7x) + (2x + 2)
Remove the common factors: 7x(x + 1) + 2(x + 1)
Rewrite as grouped factors: (7x + 2)(x + 1)

Further Reading:
 Factor By Grouping Worksheet
 methods of factoring