Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Any way other than trying linearly for all values of $k$.

share|cite|improve this question

Note that $(m+2)m+1$ is a perfect square. But it is not necessarily the smallest perfect square of the required shape.

We can if $m\ge 3$ do it a little more cheaply with $(m-2)m+1$.

I assume $k=0$ is not allowed!

share|cite|improve this answer
Feeling ashamed now. Why didn't this strike me? – Manoj R Jan 31 '13 at 6:08

If $km+1=n^2$ for some $n$ and $k=am+b$ for some $a,b\in\mathbb{Z}$, $0\le b<m$. Then $$k=\frac{n^2-1}{m}=a^2m+2b+\frac{b^2-1}{m}$$ So we can know $k$ is integer if and only if $b^2\equiv 1 \pmod{m} $.

For example, if $b=\pm 1$ we get $k=a^2m\pm 2$ and $km+1=(am\pm1)^2$

share|cite|improve this answer

There are infinite $k$ such that $km+1$ is a perfect square. One class of infinite solutions is given below.

For a given $m$, choose $k = a^2m + 2a$, i.e. $k = a(am+2)$ where $a \in \mathbb{Z}$. Hence, we get that $$km + 1 = (a^2m+2a)m + 1 = (am)^2 + 2(am) + 1 = (am+1)^2$$

share|cite|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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