I am just wondering if there is a general method in solving the Diophantine equation


where $a$ and $c$ are positive integers. This question arose because I need to find a solution to the equation $125+x^2=22y$. I am so thinking that trial and error is not a suitable method to do.

Thanks for your help.

  • $\begingroup$ Few observations which probably will help you: x is odd and y is positive. $\endgroup$ May 14, 2018 at 14:48
  • $\begingroup$ You may be interested in this page, which implements an algorithm and presents step by step solutions to second order diophantine equations $\endgroup$
    – Mathmo123
    May 14, 2018 at 17:46

2 Answers 2


I will solve just one specific case:

For this case, we need to solve $x^2 \equiv -125 \pmod{22}$

We have $22|(x^2+125)\Rightarrow22|(x^2-7+132)\Rightarrow22|(x^2-7)$ because $132$ is divisible by $22$.

So now we need to solve $x^2 \equiv 7 \pmod{22}$

Trial and error is actually suitable, but only if you notice that because $x^2-7$ is divisible by $22$, $x$ must be an odd number. This will reduce the number of cases from $22$ to $11$. With $11$ cases, we can easily set up a table like this:

\begin{array}{|c|c|c|c|c|c|c|c|c|} \hline \text{Remainder of }x\div22 &1&3&5&7&9&11&13&15&17&19&21\ \\ \hline \text{Remainder of }x^2\div22 &1&9&3&5&15&11&15&5&3&9&1\\\hline \text{Remainder of }(x^2-7)\div22 &16&2&18&20&8&4&8&20&18&2&16\\\hline \end{array}

Based on the table above, there are no positive integers $x$ satisfy $x^2 \equiv 7 \pmod{22}$, so there are no positive integers $x,y$ overall satisfy $125+x^2=22y$.

  • $\begingroup$ Thank you for the comprehensive example. But my question now is that, are there any criteria which determines the nonexistence of solutions of given Diophantine equation? $\endgroup$
    – Jr Antalan
    May 14, 2018 at 14:52
  • 1
    $\begingroup$ Unfortunately, I did not know any other way than trial and error for these types of problems. However, you can make things easier by expressing $a$ as a multiplication of primes. You can also make $c$ smaller to make it less time-consuming to solve (like what I do above: $125=132-7=22\times 6-7$. $\endgroup$
    – user061703
    May 14, 2018 at 14:57

Above equation shown below:

$x^2-ay+c=0$ -----------$(1)$

Equation $(1)$ has parametric solution for $(a,c)= (2,9)$

Where $(x,y)= ((2k+9), (2k^2+18k^2+45))$

For k=4, we get:

$(17) ^2-2(149)+9=0$


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.