Code: PU P=100 (k=78=12 (mod 22) )
Formulae:
Number N is divisible by 22 iff 12b+a = -10b+a = -(10b-a) is divisible by 22
Example:
Number N = 98 76 54 32 04 = 10 10 10 10 4 =
-10( 10 10 10 10)+4 =
-10(-10( 10 10 10+10)+4 =
-10(-10(-10( 10 10+10)+10)+4 =
-10(-10(-10(-10*10+10)+10)+10)+4 =
-10(-10(-10* 20+10)+10)+4 =
-10(-10* 8+10)+4
-10* 18+4 = 0 (mod 22)
is divisible by 22.
This method one can't omit a minus before -(10b-a), contrary do FS. The fast calculation from middle are as follow (four last lines):
10*10-10 = 90 = 2 (mod 22)
10*(-2)-10 = -30 = -8 (mod 22)
10*(--8)-10 = 70 = 4 (mod 22)
10*(-4)-4 = -44 = 0 (mod 22)
Code: PS, CR
P=11*10, (k=11). 110 = 5*22
Formulae:
Number N is divisible by 22 iff remainder from division by 110 is divisible by 22
Example:
Number N = 68940 with base P=10
Conversion to base 110, first step
[6, 8, 9, 4 | 0] = [0, 66, 22, 66 | 80] = 11*[0, 6, 2, 6] 80
Number N isn't divisible by 22 because 80=6*22+14.