Solve for d n^2=5qd