How show that $40 \mid n.$ Let $n\in\mathbb N$ s.t. $2n+1$, $3n+1$ are squares. Show that $40 \mid n.$
I have shown that $8 \mid n.$ Please help me to show $5 \mid n.$
 A: Let $2n+1=a^2$ and $3n+1=b^2$. So, $a^2+b^2=5n+2$. Consider that squares can only be congruent to $0$,$1$, or $-1$ or those congruent to one of them modulo $5$. By brute force checking (of the remainders of $a^2$ and $b^2$ when divided by $5$), it is not too hard to find that both $a^2$ and $b^2$ are congruent to $1$ modulo $5$. That means $5 \mid b^2-a^2=n$, Q.E.D.
A: For $5 | n$ we have:
$3n+1=a^2 ⇒ 3n=(a-1)(a+1)$
$a-1$ and $a+1$ are two consecutive numbers, therefore n must also be consecutive to 3 that is $n=5$ or $5 | n$
Also:
$2n+1 =b^2 ⇒ 2n=(b-1)(b+1)$
$b-1$ and $b+1$ are consecutive numbers therefore n must also be consecutive to 2 that is $n=4$ or $4|n$ . So n can be the least common multiplier(LCM)   of 4 and 5, that is $n=20$ or $20|n$. However when $20|n$ then the last digit of numbers$3n+1$ and $2n+1$ is 1, this is possible only when they are square of numbers with 1 or 9 as their last digit, i.e numbers such as 9, 11, 19,21,29,31... that indicate minimum value of n is 40 and generally 40 must divide n. 
