# how to solve the following integer equation in three variables?

How should I solve the following equation:

$a(np-1)(np+1)+b p(np+1)+cp(np-1)=1$ for integers $a$,$b$ and $c$? (n and p are odd and even integers respectively and fixed.)

Evidently $\gcd(np+1, np-1)= 1.$ So, you can solve $$b(np+1) + c (np-1) = 1.$$ Then $\gcd((np-1)(np+1),p) = 1.$ You can solve $$a(np-1)(np+1) + \lambda p = 1.$$ So far, you have $(a, \lambda b, \lambda c ).$

After that, other solutions are obtained by adding solutions to the homogeneous equation; these make a two dimensional integral lattice.

• thanks a lot, such nice simple answer. I don't know why I couldn't come up with this myself. – 7779052 Nov 5 '15 at 5:25
• btw, how can I solve the first two equations explicitly? I only need to know one set of solutions for each. – 7779052 Nov 5 '15 at 5:37
• if you have two coprime numbers, say positive $r,s,$ find the continued fraction convergents for $r/s.$ Consecutive convergents make a little cross product which is $\pm 1.$ That's what I do, it is also called the extended Euclidean algorithm; all the same. – Will Jagy Nov 5 '15 at 5:40

did it this morning. You say $np$ is even, so $np/2$ is an integer.

$$a = -1; \; \; b = -n^2 p \left( \frac{np}{2} - 1 \right); \; \; c = n^2 p \left( \frac{np}{2} \right)$$

PARI/GP is free software, covered by the GNU General Public License, and comes WITHOUT ANY WARRANTY WHATSOEVER.

Type ? for help, \q to quit.
Type ?12 for how to get moral (and possibly technical) support.

parisize = 4000000, primelimit = 500509
? x = n^2 * p^2 - 1
%1 = p^2*n^2 - 1
? y = p * (n * p + 1)
%2 = p^2*n + p
? z = p * (n * p - 1)
%3 = p^2*n - p
?
? a = -1
%4 = -1
? b = - n^2 * p * ( (n * p / 2) - 1   )
%5 = -1/2*p^2*n^3 + p*n^2
? c =  n^2 * p *  (n * p / 2)
%6 = 1/2*p^2*n^3
?
? a * x + b * y + c * z
%7 = 1
?