Finding the remainder. Let $a,b$ be positive integers such that $7$ divide $a^2+b^2$ .How to find the remainder when we divide $ab-1$ by $7$

Note that $7$ divides $a^2+b^2$ if and only if $7$ divides both $a$ and $b$.
You can prove this in two ways. One way is to calculate $a^2+b^2$ modulo $7$ for all possibilities. This is not as tedious as it sounds, since a square is congruent to $0$, $1$, $4$, or $2$ modulo $7$. No sum of these is congruent to $0$ modulo $7$ except $0+0$.
Or else we can appeal to the general theorem that if $p$ is a prime of the form $4k+3$, then $-1$ is not a quadratic residue of $p$. If $a^2+b^2\equiv 0\pmod{p}$, then $b^2\equiv -a^2\pmod{p}$. If $b\not\equiv 0\pmod{p}$, then multiplying both sides by the inverse of $b$ modulo $p$, we would obtain $(ab^{-1})^2\equiv -1\pmod{p}$, contradicting the fact that $-1$ is not a quadratic residue of $p$. Thus the modular inverse of $b$ cannot exist, and therefore $b\equiv 0\pmod{p}$. Similarly, $a\equiv 0\pmod{p}$.
