That's the same as asking
"What digits can squares of integers end in?"
and
"What digits can squares of integers NOT end in?"
The last digit of the product of any two
integers is always the same digit as the
last digit product of their last two
digits. So we look at these products:
0×0 = 0
1×1 = 1
2×2 = 4
3×3 = 9
4×4 = 16
5×5 = 25
6×6 = 36
7×7 = 49
8×8 = 64
9×9 = 81
Those all end with 0,1,4,6,or 9
So r can be 0,1,4,6, or 9
So r cannot be 2,3,5,7, or 8
Edwin