Linear Diophantine Equations
The equation has integer solutions iff . From one solution (found by the extended Euclidean algorithm), all solutions are , with and .
Geometrically the solutions are the lattice points on a line, spaced evenly along it. The spacing is the smallest integer step along the line, which is why appears: with the naive step skips solutions. Constraints like "positive solutions" become inequalities in — usually leaving finitely many.
Does have integer solutions? The left side is always a multiple of , and is not: none. What about ? Now , and , works (). With , the general solution is , .
Find all positive solutions of . First solve : Euclid gives . Multiply by : , . General: , . Positivity: needs , and needs . So give .
A farmer spends exactly on cows at and sheep at , buying at least one of each. In how many ways? , or . Mod : , so . Try (the next, , costs too much): . Four ways.
Stepping by when . For , starting at and stepping by reaches but skips : . The true step is .
In how many ways can be made from -cent and -cent stamps (order irrelevant)?
Show the answerHide the answer
with . Since and , , so is a multiple of : give ( is too much). 3 ways.
Factoring and Bounding
becomes : add the missing constant to complete the product, then list factor pairs. More generally, get one side to factor and the other to be a constant, and the equation reduces to finitely many cases. When nothing factors, bound a variable by size.
The trick is a change of variables that turns a hyperbola into one with axes parallel to the coordinate axes; the integer points on are the divisor pairs of , of which there are finitely many. For equations without such a factorization, order the variables () and use the smallest one to bound the whole equation.
Solve in positive integers. The product expands to , so add to both sides: . Since and , the factors are at least and , which rules out the negative pairs and . The pairs and give and .
Find all positive integers with . Clear denominators: , so and . Could both factors be negative? Then and would each be at least , making the product at most : impossible. So both are positive divisors of , and has of them: ordered solutions, from to through .
Find all positive integers with . The largest term is , so and ; and . If , then forces , . If , then gives : gives , gives . Answer: , , .
Forgetting negative factor pairs when the variables may be negative, and forgetting that and are different pairs when and play different roles. In the unit-fraction example the negative pairs had to be ruled out by an argument, not ignored.
Find all positive integer solutions of .
Show the answerHide the answer
Add : , with both factors at least . Pairs give — six solutions.
Congruence Obstructions
If an equation has an integer solution, reducing it gives a solution modulo every . So one modulus in which the equation is impossible proves there are no integer solutions. The useful tables: squares are and ; cubes are .
This is the contrapositive of reduction: integer solution solution mod . The art is choosing so the relevant powers take few values: squares suggest or , cubes or , powers of suggest . A modulus can only ever prove impossibility; it can never prove that a solution exists.
Solve . Squares are for even numbers and for odd ones, so or . But . No solutions — without trying a single pair.
Solve in positive integers. Rewrite as : both factors are powers of , and they differ by . The only powers of two apart are and , so , , : indeed . Unique factorization did the work — a product equal to a power of has only powers of as factors.
Show has no integer solutions. Cubes mod : give , and , : every cube is or . Three of them sum to something between and , never . But . Impossible.
Taking a passed test as proof of a solution. gives , which the table allows — yet there is no solution ( are , none a square). Meanwhile also passes and does have solutions, such as . A congruence can only close doors.
Find all positive integers for which is a perfect square.
Show the answerHide the answer
For , , so ; but squares are or . So only remain, giving and , neither a square. There are none.
Why It Works
Let and suppose and both solve . Subtracting, ; divide by : . Now and are coprime, so by Euclid's lemma divides : write . Substituting back gives . So every solution has the stated form, and every such pair is a solution by direct substitution. Nothing is missed and nothing extra is included.