You can attack the problem with Division Algorithm.Originally Posted byOReilly

Meaning any number must be exactly in one of these forms,

.........................

When you square then, you get, the only possibilities,

Thus, remainders are 0,1,4,7