I am not sure if you are familiar with modulos. The solution relies on the use of it.
Show that for the Rem(n,4) you will just need to observe the last two digits of an n digit number. (I'm assuming Rem stands for remainder)
First note that any n digit number can be rewritten using the linear combination of place digits (i.e ones, tens,etc.) multiplied by some power to the 10 ( note the power of 10 is one less the the place of the digit).
let x be your n digit number then in the form the are natural numbers
Then noting the earlier observation
factoring a from every term except the last 2 (this is possible since )
( The '=' should be replaced with the congruent symbol)
Thus evaluation of the remainder of an n digit number when divided by 4 is equivalent to the the remainder of the last two digits divided by 4:
For Rem (n,8) try the same technique but factor a 10^3 from all digits except the last 3 and apply (Mod 8).
Hope this helps.