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.
 A: If $x\equiv1(mod\ 3)$, we have $7n+1\equiv2(mod\ 3)$.
If $x\equiv2(mod\ 3)$, we have $5n+1\equiv2(mod\ 3)$.
But a perfect square cannot be congruent 2 mod 3, so x must be divisible by 3.
The remainders modulo 8 of the numbers are :
? for(n=0,7,print(n," ",Mod(7*n+1,8),"  ",Mod(5*n+1,8)))
0 Mod(1, 8)  Mod(1, 8)
1 Mod(0, 8)  Mod(6, 8)
2 Mod(7, 8)  Mod(3, 8)
3 Mod(6, 8)  Mod(0, 8)
4 Mod(5, 8)  Mod(5, 8)
5 Mod(4, 8)  Mod(2, 8)
6 Mod(3, 8)  Mod(7, 8)
7 Mod(2, 8)  Mod(4, 8)
?
Since the only quadratic residues modulo 8 are 0,1,4 , we must have $n\equiv0$ (mod 8)
Hence, 24 must divide n.
A: 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.
