Distributing Constant To Factored Trinomial I am using the quadratic formula to turn $ax^2 + bx +c$ into $a(x-x_1)(x-x_2)$. However, I am having difficulty finding a mathematical way to distribute the $a$ into $(x-x_1)$ and $(x-x_2)$ like $(a_1x-a_1x_1)(a_2x-a_2x_2)$ in such as to satisfy $a=a_1\times a_2$, $a_1\in\mathbb{W}$, $a_2\in\mathbb{W}$, $x_{int}a_1\in\mathbb{W}$, and $x_{int}a_2\in\mathbb{W}$ only if possible. I am attempting to do this using only basic math (i.e. addition, subtraction, multiplication, division, exponentiation (including roots), modulo, unary negative, and unary positive (absolute value)), minimal if/then statements, GCF, GCD, and the ability to turn a decimal into a (potentially "improper") fraction and get the numerator and the denominator. For 
a very simple example, I would want to turn this:
$$f(x) = 12\times(x + \frac{5}2)\times(x + \frac{1}3)$$
Into this:
$$f(x) = (4\times{x} + 10)\times(3\times{x} + 1)$$
Yes, I can easily do the simple example above in my head. But, the actual numbers I am dealing with are much much bigger. Thus, I need a mathematical way to punch it into a calculator and calculate it.
So far, I have made not much progress in my attempts to devise a way to distribute $A$. So, how would I go about distributing A to meet all of the criteria if the criteria are attainable? Any any all constructive advice/criticism is welcome.
 A: A rather simple way to check whether this is possible may be as follows. The possibility to "distribute" $A $ in such a way, considering that $a $, $a_1$, $a_2$, $a_1x_1$, and $a_1x_2$ have all to be integer, exists if:


*

*$x_1$ and $x_2$ are both rational numbers;

*expressing $x_1$ and $x_2$ as irreducible fractions,  calling $d_1$ and $d_2$ the corrisponding denominators and $d $ their product $d_1d_2\,$, $a $ is divisible by $d $.
If these conditions are satisfied, setting $a=kd \,$ with  $k $ integer, the resulting expression becomes
$$a(x−x1)(x−x2) \\=k (d_1x-d_1x_1)(d_2x-d_2x_2)$$
where the factor $k $ can then be incorporated - if one wants to avoid it in the final expression - in any of the two quantities in brackets.
For the very simple example reported in the OP, $x_1=5/2\,\,$ and $x_2=1/3\,\,$ are both rational, already expressed as irreducible fractions. Their denominators are $d_1=2\,\,$ and $d_2=3\,\,$, with a product $d=2 \cdot 3=6\,\,\,$. Since $a =12=2 \cdot 6\,\,\,$, taking $k=2\,$ we get
$$12 \left( x+\frac {5}{2} \right) \left (x+\frac {1}{3} \right) \\= 2 \left(2x+2\frac {5}{2} \right)
\left(3x+3\frac {1}{3} \right) \\ =2 (2x+5)(3x+1) $$
which can be written, if one wants to eliminate the factor outside the brackets, as $ (4x+10)(3x+1) \,\,\,$ or $ (2x+5)(6x+2) \,\,$. 
This approach should allow you to rapidly check the feasibility of the trasformation, even for large values of $a $, $x_1$, and $x_2$. 
