Arthur’s (in)famous puzzles — David’s solutions

The aim is to find non-negative integer values for A, B and N which satisfy:
           A2 + B2
A B + σ
  =   N             where σ = ±1

This can be rearranged as a quadratic equation in A.
      A2 + B2   =   N A B + σ N
      A2N A B – σ N + B2   =   0
So for any solution An–1 , Bn–1 there is another solution An , Bn in which:
      Bn = Bn–1
      An = N Bn–1 – An–1
As the problem is invariant under interchange of A and B, we can obtain multiple solutions by swapping An and Bn:
      An = Bn–1
      Bn = N Bn–1 – An–1
For most starting values of A0 and B0 this gives an infinite series, but not necessarily so as is evidenced by N = 1, A0 = 1, B0 = 0 (This is only a solution for σ = +1.):
n = 01234567...
An = +10–1–10+1+10...
Bn = 0–1–10+1+10–1...

Let B0 be the value of B of smallest magnitude for any given value of N for which solutions exist, and A0 be the corresponding solution for A (for which there will be two solutions). Because the problem is invariant under interchange of A and B, each of the values A0 is also a valid value of B, and thus cannot be of smaller magnitude than B0.
      2 A0 = N B0 ± √(N 2 B02 – 4 B02 + 4 σ N)
      | A0 |   ≥   | B0 |
      \   A02   ≥   B02
The smaller of the two values of A0 is obtained by choosing the minus sign, thus:
      [ N B0 – √(N 2 B02 – 4 B02 + 4 σ N) ]2   ≥   4 B02
      N 2 B02 + N 2 B02 – 4 B02 + 4 σ N – 2 N B0 √(N 2 B02 – 4 B02 + 4 σ N)   ≥   4 B02
      2 N 2 B02 – 8 B02 + 4 σ N – 2 N B0 √(N 2 B02 – 4 B02 + 4 σ N)   ≥   0
      B02 (N 2 – 4) + 2 σ N   ≥   N B0 √(N 2 B02 – 4 B02 + 4 σ N)

We restrict consideration situations where both sides will be non–negative (e.g. N > 2, σ = +1), so we can square the inequality:
      B04 (N 2 – 4)2 + 4 σ N B02 (N 2 – 4) + 4 N 2   ≥   N 2 B02 (N 2 B02 – 4 B02 + 4 σ N)
      B04 (N 2 – 4)2 + 4 σ N B02 (N 2 – 4) + 4 N 2N 2 B04 (N 2 – 4)   ≥   4 σ N3 B02
      B02 (N 2 – 4) [B02 (N 2 – 4) + 4 σ NN 2 B02] + 4 N 2   ≥   4 σ N3 B02
      B02 (N 2 – 4) [ 4 σ N – 4 B02 ] + 4 N 2 – 4 σ N3 B02   ≥   0
      B02 (N 2 – 4) (σ NB02) + N 2 – σ N3 B02   ≥   0
      B02 [ (N 2 – 4) (σ NB02) – σ N3 ] + N 2   ≥   0
      B02 (4 B02 – 4 σ NN 2 B02) + N 2   ≥   0
      N 2   ≥   N 2 B04 + 4 σ N B02 – 4 B04
      0   ≥   B04 (N 2 – 4) + 4 σ N B02N 2
This factorises (note σ2 = 1) to:
      0   ≥   [B02(N + 2) – σ N] [B02(N – 2) + σ N]

For σ = +1 and N ≥ 2, the term in the second square bracket is always positive:
      \     B02(N + 2) – N   ≤   0
           and   B02   ≤   N
N + 2
  <   1

Thus for any value of N ≥ 2 for which there are integer solutions for A and B, there will be a solution in which   B = 0   and A2 = N.
For N = 1, we still have a solution in which   B = 0   and A2 = N.
Thus any integer value of A gives an integer value of N which is always a perfect square.

For σ = –1 the discriminant in the quadratic equation solving for A will be negative unless N > 2, so the term in the first square bracket is always positive:
      \     B02(N – 2) – N   ≤   0
           and   B02   ≤   N
(N – 2)
  =   1   +   2
N – 2

This gets smaller for increasing N, starting with the value 3 for N = 3 so that:
      B0   <   √3
i.e. whatever the value of N for which there are solutions there will always be a solution for B0 = 1.

We now look for those values of N for which there is a solution with B = 1.
We can substitute B = 1 in our quadratic equation for A, and observe that for an integer solution, the discriminant must be a perfect square.
We introduce integers Q and Z such that:
      Z2 = N 2 – 4 N – 4
      0 = N 2 – 4 N – 4 – Z2
      N = 2 ± Q
      Q2 = 4 + 4 + Z2
      ( QZ ) ( Q + Z ) = 8
             where Q and Z are non–negative integers, and Q > Z.   \   Z < 4.
      Z = 0   :   Q2   =   8
      Z = 1   :   Q2   =   8 + 1   \     Q = 3   and   N = 5
      Z = 2   :   Q2   =   8 + 4   =   12
      Z = 3   :   Q2   =   8 + 9   =   17
Therefore the only solutions for B = 1 have N = 5.
Combined with our earlier proof that all sets of solutions for a given N must contain a solution in which B = 1, this proves that the only value of N for which integer solutions for A and B exist is 5.