If (n==odd) do the divisibility test of 3 for n; if (divisible) rem=3; else rem=1or5; Then do the divisibility test of 3 for n-1; if (divisible) rem=1; else rem=5;
If (n==even) do the divisibility test of 3 for n; if (divisible) rem=0; else rem=2or4; Then do the divisibility test of 3 for n-1; if (divisible) rem=4; else rem=2;