Partition next digit search space by gcd

The divisibility test for a sequence of length equal to a factor of the
base is to check the last digit of the sequence for divisibility by the
factor.

A base 10 sequence is divisible by 5 if the last digit is divisible by
5. This reduces the choices for the fifth digit to {5}.

If the sequence length is not a direct factor we can still reduce the
choices to those digits with the same gcd. The choices for the fourth
digit must be divisible by 2, so we can choose from {2, 4, 6, 8}.