I was trying to approach an equation of the type:

$$ \alpha m + \beta = n^2 $$

where $\alpha$ and $\beta$ are given integer constants and $m$ and $n$ are integer to be found. Is there a standard way to approach equations like these? If so, can you share me a link or some useful material?

Thanks, Dave

  • 1
    $\begingroup$ Here this swc.math.arizona.edu/aws/2006/06CohenLectures.pdf if you're interested, although it might be a bit too comprehensive depending on what you're looking for. $\endgroup$ – Ryan Greyling Jul 26 at 22:26
  • $\begingroup$ The first thing that jumps out at me is that $\alpha m+\beta$ has to be a square, which implies that $\alpha m+\beta$ is a multiple of $4$ or $1$ greater than a multiple of $4$. $\endgroup$ – Ryan Greyling Jul 26 at 22:27

Your equation of

$$\alpha m + \beta = n^2 \tag{1}\label{eq1A}$$

means that if $\alpha = 0$, there's a solution only if $\beta$ is a perfect square, with $n$ then being $\sqrt{\beta}$ and $m$ being any integer.

For $\alpha \neq 0$, one other restriction to consider is if there's any prime $p$ where the # of factors of it in $\beta$, call it $q$, is odd and the number of factors of $p$ in $\alpha$ is $\gt q$. In those cases, there are no solutions since $\alpha m + \beta$ would have the odd $r$ factors of $p$, but $n^2$ must have an even number of factors of $p$.

Apart from the restrictions mentioned above, note you have

$$\beta \equiv n^2 \pmod{\alpha} \tag{2}\label{eq2A}$$

i.e., $\beta$ must be a quadratic residue modulo $\alpha$. Any $n$ which satisfies \eqref{eq2A} will then have a corresponding $m$ from \eqref{eq1A} of $m = \frac{n^2 - \beta}{\alpha}$. As for finding an $n$, as suggested by Robert Israel's comment, the Complexity of finding square roots Wikipedia article section describes several algorithmic methods.

However, note if $\beta$ is not a quadratic residue modulo $\alpha$, then there are no solutions. For example, if $\alpha$ is a multiple of $3$ and $\beta \equiv 2 \pmod{3}$, there are no solutions since $2$ is not a quadratic residue modulo $3$, i.e., there's no $n$ such that $n^2 \equiv 2 \pmod{3}$.

| cite | improve this answer | |
  • $\begingroup$ For methods of finding $n$, see Wikipedia $\endgroup$ – Robert Israel Jul 26 at 22:50
  • $\begingroup$ @RobertIsrael Thanks for your suggestion. I added the Wikipedia article section link to my answer. $\endgroup$ – John Omielan Jul 26 at 22:56

$\alpha m + \beta = n^2$

Given $(\alpha,\beta)$ as,

$(\alpha,\beta)$=$[w^2,4w^2(k^2-1)]$ then,




For, $k=3$, we get:

$(\alpha,\beta)$=$(9,288)$ and


| cite | improve this answer | |

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.