For a positive integer $n$ both $5n+1$ and $7n+1$ are perfect squares. Show that $n$ is divisible by 24. My try:

$5n + 1 = k^2$
$7n +1 = \frac{7k^2-2}5$

Just don't know how to proceed after this. Please help.

Given, both $5n+1$ and $7n+1$ are perfect squares, We have to prove, $24\mid n$
Consider the sum: $(5n+1)+(7n+1)=12n+2$. This number leaves the remainder $2$ when divided by $3$. This is possible only under three situations:
a) $5n+1\equiv 2\mod3$ and $7n+1\equiv 0\mod3$
b) $5n+1\equiv 1\mod3$ and $7n+1\equiv 1\mod3$
c) $5n+1\equiv 0\mod3$ and $7n+1\equiv 2\mod3$  
However, a perfect square never leaves remainder $2$ when divided by $3$. Hence, cases (a) and (c) cannot exist. The only choice, is thus case (b). Hence, both $5n+1$ and $7n+1$ leave remainder $1$ when divided by $3$. Hence, both $5n$ and $7n$ are divisible by $3$. As _gcd_$(5,3)=1$ and _gcd_$(7,3)=1$, we conclude that $3$ divides $n$.  
Exactly similar argument holds for divisibility by $8$: The sum $12n+2$ leaves remainder $2$ or $6$ when divided by $8$.
But, $k^2\equiv 0,1,4 \mod 8$.
Thus, the only way two perfect squares can add up to a number that leaves remainder $2\mod 8$ is when each of them leaves remainder $1 \mod 8$. Hence, both $5n$ and $7n$ are divisible by $8$, and as $5$ and $7$ both are coprime with $8$, hence $8\mid n$.  
Finally, because $8$ and $3$ are coprime, hence their product will also divide $n$. Hence $24\mid n$. Thus proved.
