How do I find all possible integer solutions for a product of two variables?

492 Views Asked by At

For example, let us say I want to find all the possible integer solutions that will return the product of two. Now, following the formula that I was toying with.

n!=0, P = 10/n

I have a list named np or short for n*p. The wolfram website will not show how it came up with the integer solutions.

np-list

{n == -10, P == -1}

{n == -5, P == -2}

{n == -2, P == -5}

{n == -1, P == -10}

{n == 1, P == 10}

{n == 2, P == 5}

{n == 5, P == 2}

{n == 10, P == 1}

I decided to check if the solution was correct with a formula that I randomly plugged into the website. It seems to be true.

P=1

p=p

n=n

P∗10/n=np

What steps would one get to 8 possible integer solutions?

1

There are 1 best solutions below

0
On BEST ANSWER

This is called integer factorization. In general, finding all pairs of integers $(a,b)$ so that $ab=n$ is equivalent to finding the prime factorization of $n$.

There are various methods to do this. The simplest is trial division:

  1. Does $2$ divide $n$? If so, add $2$ to our list and replace $n$ with $n/2$.

  2. Does $3$ divide $n$? If so, add $3$ to our list and replace $n$ with $n/3$.

et cetera. Using this method, we get $10=2\cdot 5$, where $2$ and $5$ are both prime numbers.

To find all factor pairs $a,b$, just take all subsets of the set of prime factors (here, they are $\{\},\{2\},\{5\},\{2,5\}$), multiply them together, and take the remaining factors and multiply them. To find all integer pairs (not just positive integers), take each pair $(a,b)$ and add the pair $(-a,-b)$ as well.