How many positive integers $n$ are there such that $(7n + 1)$ is a perfect square and $(3n + 1) < 2008$ ?
What I Tried: We have $(3n + 1) < 2008$
$\rightarrow n < 669$ .
Now, $(7n + 1) = k^2$ for some $k$ .
$$\rightarrow 7n = (k + 1)(k - 1)$$
Now I have to count all the $n$ so that after multiplied by $7$ , gives a product same as the product of $2$ consecutive numbers with a gap of one. I know that $n = 5,9$ are two solutions, but there are more values so that when multiplied by $7$ gives a valid solution, like $k = 24,32$ .
The problem I am facing is, is there any elegant way here to count all the solutions?
Can anyone help me?
As you mentioned, $7n = (k + 1)(k - 1)$
So $7$ is a factor of either $(k+1)$ or $(k-1)$
which means $k = 7 a -1$ or $7a+1$.
If $k = 7a - 1$, $n = 7a^2 - 2a \lt 669$ as you observed.
Taking $a = 1, 2, ...$ you get the values but if you only have to count the number of solutions, it is easy to see that $a \leq 9$ given the constraint $n \lt 669$.
Similarly take $k = 7a + 1$ and see how many solutions given the constraint of $n \lt 669$.