“Fresh sale of individual modules has been closed. Visit anaprep.com for information on new products and write to us for special offers”

## Algebra - Integer Solutions to an Equation in Two Variables

If you have been preparing for a standardised test for a while now, you must have come across a Data Sufficiency question which is similar to the following:

Question: A boy goes to a supermarket and buys some pencils and erasers. The cost of each pencil is \$0.3 and cost of each eraser is \$0.5. If he bought at least one pencil and at least one eraser and the number of pencils he bought was not four, how many pencils did he buy?

Statement I: He paid a total of \$4.20

Statement II: He bought three erasers.

Solution: I am sure, by using the first statement, most of you will be able to come up with the following equation: 0.3p + 0.5e = 4.2 and then, by multiplying both sides by 10, you will get 3p + 5e = 42
(p - the number of pencils, e - the number of erasers)

What next? This is the equation of a line and has infinite solutions i.e. for every value of p, exists a value of e.
e.g. When p = 0, e = 42/5; when p = 0.1, e = 8.34; when p = 1, e = 39/5 and so on… Then, should I say that from this statement alone, he can buy the pencils and erasers in an infinite number of ways e.g. 0 pencils and 42/5 erasers or 0.1 pencils and 41.7/5 erasers or 1 pencil and 39/5 erasers etc? Does it mean we need statement 2 as well to get the number of pencils? Actually, no! We don’t need the second statement to get our answer. Let’s see why.

There are certain constraints to the acceptable solutions. Can I buy 42/5 = 8.4 erasers? I can buy 8 erasers or 9 erasers but how can I buy 8.4 erasers? So what we are looking for is integral values of p and e. Even though it is not mentioned, our common sense says it has to be so. This is a constraint on possible solutions and will narrow down the acceptable values.

Consider the equation again: 3p + 5e = 42

One set of integral solutions to this equation is p = 14, e = 0 (I will discuss how I got to this later.)
When you put p = 14 and e = 0 above, you get 3*14 + 5*0 = 42. Here, 3p = 42 and 5e = 0 and they add up to give 42. What if I want to get 42 in another way? I can decrease 3p by some amount and will have to increase 5e by the same amount to get the same sum of 42 e.g. we decrease 3p by 1 and increase 5e by 1 to get 41 + 1 = 42. So 3p was 42, but now we want 3p to be 41. What should p be? p should be 41/3 but this is not an integral value! We are looking for integral solutions only. Then let’s try to decrease p instead of 3p to ensure that we get integral values of p. If p = 13 instead of its previous value of 14, we get 3p = 39. (We decreased 3p by 3.)

Now, I must increase 5e by 3 to get the same sum of 42. 5e was 0 and needs to be 3 now. What will e be now? e = 3/5. Unfortunately, the problem is still the same. We need integral values of p and e, both. I can increase 5e in blocks of 5 only i.e. if e = 0, 5e = 0; e = 1, 5e = 5; e = 2, 5e = 10 etc.
Now the problem is that 3p can be decreased only in blocks of 3 and 5e can be increased only in blocks of 5. But the decrease in 3p has to be offset by the increase in 5e! Therefore, we should decrease/increase them in blocks of 15 (lowest common multiple of 3 and 5). So when I try to decrease 3p by 15, p decreases by 5 (the second term, 5e, has 5 as the co-efficient) and when I try to increase 5e by 15, e increases by 3 (the co-efficient of the first term). The table given below will make it clearer.

and so on…

Note that in second, third and fourth rows, we have been decreasing 3p and increasing 5e. We could do the opposite as done in the last two rows of the table above. We could increase p by 5 and decrease e by 3 to get more solutions. Once we have one solution, we can figure out an infinite number of solutions. Then is our answer still infinite? Why the heck did we do all this work then? We should have just marked our answer as (C) and moved on.

Actually, there is another constraint. Can the number of pencils or erasers be negative? Also, since he buys at least one pencil and at least one eraser, p and e cannot be 0 (so we discard the first solution) Then, a solution is one where values of p and e are positive integers.

Go back to the table. After the third row of solutions, if you keep decreasing 3p, p will be negative every time. Look at the last row - if you keep decreasing 5e, e will remain negative. Therefore, there are only two solutions (p = 9, e = 3) and (p = 4, e = 6). Since our question stem mentions that p is not equal to 4, we discard the second solution and retain just the first one. This means that statement (1) above is sufficient to get the answer.

Now we come back to ‘How do you get the first solution’. Simple – by brute force. Here it is easy since 42 is a multiple of 3. Then we know that p can be 14 to give 42 and 5e can be 0.

An equation such as 3p + 5e = 49 is trickier.

First, I check for e = 1. Reduce 49 by 5 to get 44 and then check – is 44 divisible by 3? – No.

Then check for e = 2. Reduce 44 by 5 again to get 39 – is 39 divisible by 3? – Yes!

This means 3p can be 39 and 5e can be 10 giving us p = 13 and e = 2. This would be our first solution and would lead us to more, possibly. How many positive integral solutions will this equation have?

Let me leave you here with some other things to ponder upon:

- What if I replace the equation above by 3x + 6y = 40?

- Should coefficients of x and y be co-prime?

- And, a trickier thing to think about - how many integral solutions would 3x - 5y = 42 have?