I've made a brute-force version of this algorithm
It doesn't use the root of d (since obviously we don't know how you're meant to use that to do this), but it's useful for considering the context in which this function fits within the entire algorithm. It doesn't do (1,c) for even cs since n would have .5 at the end with an odd a+b (so those cells aren't in the grid).
import java.util.;public class brute{ public static void main(String[] args){ int e = Integer.parseInt(args[0]); int f = Integer.parseInt(args[1]); int d = (e-f-1)/2; int c = (dd)+e; int twod = d2; int roottwod = (int)Math.floor((int)Math.sqrt(twod)); System.out.println("c="+c+", d="+d+", e="+e+", f="+f+", 2d="+twod+", sqrt(2d)="+roottwod); for(int i=0; i<((((1+c)/2)-d)+1); i++){ int aplusb = (i+d)2; int x = ((int)Math.floor((int)Math.sqrt(((d+i)*(d+i))-c)))-i; int testa = d-x; int testb = aplusb-testa; if(testa*testb==c){ System.out.println(i + " is a valid n, with a=" + (int)testa + " and b=" + (int)testb); } } }}
So you input e and f values (f has to be negative) and it outputs every valid n value for that pairing