A Diophantine equation is an equation in which only integer solutions are allowed.

Hilbert's 10th problem asked if an algorithm existed for determining whether an arbitrary Diophantine equation has a solution. Such an algorithm does exist for the solution of first-order Diophantine equations. However, the impossibility of obtaining a general solution was proven by Yuri Matiyasevich in 1970 (Matiyasevich 1970, Davis 1973, Davis and Hersh 1973, Davis 1982, Matiyasevich 1993) by showing that the relation n=F_(2m) (where F_(2m) is the (2m)th Fibonacci number) is Diophantine. More specifically, Matiyasevich showed that there is a polynomial P in n, m, and a number of other variables x, y, z, ... having the property that n=F_(2m) iff there exist integers x, y, z, ... such that P(n,m,x,y,z,...)=0.

A linear Diophantine equation (in two variables) is an equation of the general form
 ax+by=c,
(1)

where solutions are sought with a, b, and c integers. Such equations can be solved completely, and the first known solution was constructed by Brahmagupta. Consider the equation

 ax+by=1.
(2)

Now use a variation of the Euclidean algorithm, letting a=r_1 and b=r_2

r_1=q_1r_2+r_3
(3)
r_2=q_2r_3+r_4
(4)
r_(n-3)=q_(n-3)r_(n-2)+r_(n-1)
(5)
r_(n-2)=q_(n-2)r_(n-1)+1.
(6)

Starting from the bottom gives

1=r_(n-2)-q_(n-2)r_(n-1)
(7)
r_(n-1)=r_(n-3)-q_(n-3)r_(n-2),
(8)

so

1=r_(n-2)-q_(n-2)(r_(n-3)-q_(n-3)r_(n-2))
(9)
=-q_(n-2)r_(n-3)+(1+q_(n-2)q_(n-3))r_(n-2).
(10)

Continue this procedure all the way back to the top.

Take as an example the equation

 1027x+712y=1
(11)

and apply the algorithm above to obtain

  1027 = 712·  1+  315;  712 = 315·  2+  82;  315 = 82·  3+  69;  82 = 69·  1+  13;  69 = 13·  5+  4;  13 = 4·  3+  1;    |; |; |; |; |; v;     1= -165·  1027+  238·  712; 1= 73·  712-  165·  315; 1= -19·  315+  73·  82; 1= 16·  82-  19·  69; 1= -3·  69+  16·  13; 1= 1·  13-  3·  4; 1= 0·  4+  1·  1^; |; |; |; |; |; |
(12)

The solution is therefore x=-165, y=238.

The above procedure can be simplified by noting that the two leftmost columns are offset by one entry and alternate signs, as they must since

1=-A_(i+1)r_i+A_ir_(i+1)
(13)
r_(i+1)=r_(i-1)-r_iq_(i-1)
(14)
1=A_ir_(i-1)-(A_iq_(i-1)+A_(i+1)),
(15)

so the coefficients of r_(i-1) and r_(i+1) are the same and

 A_(i-1)=-(A_iq_(i-1)+A_(i+1)).
(16)

Repeating the above example using this information therefore gives

  1027 = 712·  1+  315;  712 = 315·  2+  82;  315 = 82·  3+  69;  82 = 69·  1+  13;  69 = 13·  5+  4;  13 = 4·  3+  1;    |; |; |; |; |; v;     (-)  165·  1+  73 = 238; (+)  73·  2+  19 = 165; (-)  19·  3+  16 = 73; (+)  16·  1+  3 = 19; (-)  3·  5+  1 = 16; (+)  1·  3+  0 = 3; (-)  0·  1+  1 = 1^; |; |; |; |; |; |
(17)

and we recover the above solution.

Call the solutions to

 ax+by=1
(18)

x_0 and y_0. If the signs in front of ax or by are negative, then solve the above equation and take the signs of the solutions from the following table:

equationxy
ax+by=1x_0y_0
ax-by=1x_0-y_0
-ax+by=1-x_0y_0
-ax-by=1-x_0-y_0

In fact, the solution to the equation

 ax-by=1
(19)

is equivalent to finding the continued fraction for a/b, with a and b relatively prime (Olds 1963). If there are n terms in the fraction, take the (n-1)th convergent p_(n-1)/q_(n-1). But

 p_nq_(n-1)-p_(n-1)q_n=(-1)^n,
(20)

so one solution is x_0=(-1)^nq_(n-1), y_0=(-1)^np_(n-1), with a general solution

x=x_0+kb
(21)
y=y_0+ka
(22)

with k an arbitrary integer. The solution in terms of smallest positive integers is given by choosing an appropriate k.

Now consider the general first-order equation of the form

 ax+by=c.
(23)

The greatest common divisor d=GCD(a,b) can be divided through yielding

 a^'x+b^'y=c^',
(24)

where a^'=a/d, b^'=b/d, and c^'=c/d. If dc, then c^' is not an integer and the equation cannot have a solution in integers. A necessary and sufficient condition for the general first-order equation to have solutions in integers is therefore that d|c. If this is the case, then solve

 a^'x+b^'y=1
(25)

and multiply the solutions by c^', since

 a^'(c^'x)+b^'(c^'y)=c^'.
(26)

D. Wilson has compiled a list of the smallest nth powers of positive integers that are the sums of the nth powers of distinct smaller positive integers. The first few are 3, 5, 6, 15, 12, 25, 40, ...(Sloane's A030052):

3^1=1^1+2^1
(27)
5^2=3^2+4^2
(28)
6^3=3^3+4^3+5^3
(29)
15^4=4^4+6^4+8^4+9^4+14^4
(30)
12^5=4^5+5^5+6^5+7^5+9^5+11^5
(31)
25^6=1^6+2^6+3^6+5^6+6^6+7^6+8^6+9^6+10^6+12^6+13^6+15^6+16^6+17^6+18^6+23^6
(32)
40^7=1^7+3^7+5^7+9^7+12^7+14^7+16^7+17^7+18^7+20^7+21^7+22^7+25^7+28^7+39^7
(33)
84^8=1^8+2^8+3^8+5^8+7^8+9^8+10^8+11^8+12^8+13^8+14^8+15^8+16^8+17^8+18^8+19^8+21^8+23^8+24^8+25^8+26^8+27^8+29^8+32^8+33^8+35^8+37^8+38^8+39^8+41^8+42^8+43^8+45^8+46^8+47^8+48^8+49^8+51^8+52^8+53^8+57^8+58^8+59^8+61^8+63^8+69^8+73^8
(34)
47^9=1^9+2^9+4^9+7^9+11^9+14^9+15^9+18^9+26^9+27^9+30^9+31^9+32^9+33^9+36^9+38^9+39^9+43^9
(35)
63^(10)=1^(10)+2^(10)+4^(10)+5^(10)+6^(10)+8^(10)+12^(10)+15^(10)+16^(10)+17^(10)+20^(10)+21^(10)+25^(10)+26^(10)+27^(10)+28^(10)+30^(10)+36^(10)+37^(10)+38^(10)+40^(10)+51^(10)+62^(10).
(36)