Finding the Stolt fundamental solutions for x2 – dy2 = n, d > 0 and not a perfect square, n a multiple of 4

The algorithm: We create a list of Nagell fundamental solutions and output a list of Stolt fundamental solutions (SFS's) of x2 – dy2 = n, where 4 divides n and n is nonzero.

Let e1 = x1 + y1√d be the least positive solution of x2 – dy2 = 1 and e4 = (x4 + y4√d)/2 be the least positive solution of x2 – dy2 = 4.
There are three possibilities: (See On the Diophantine equation u2 – Dv2 = 4N, Arkiv för Matematik 2 (1951), 1-23.)

  1. If e1 = e4, then the Stolt and Nagell classes are identical.
  2. If e1 = e42, each Stolt class is composed of two Nagell classes.
  3. If e1 = e43, each Stolt class is composed of three Nagell classes.
See Note.

The program is a BCMath version of BC program.

Enter d (positive, nonsquare and < 1020):
Enter n (≠ 0 and divisible by 4):

Last modified 31st January 2020
Return to main page