# Name for this Algorithm

I've managed to prove a bunch of properties about this algorithm that I came up with. I'm now curious to know it's name to see what other people have done.

Given a number in base b $$N_0 = b N_X + N_L, \qquad 0 \leq N_L \leq b-1$$ And a divisor also in base b $$D = b D_X + D_L, \qquad 0 \leq D_L \leq b-1$$

($$N_L$$ and $$D_L$$ are the last digits of N and D)

Then compute $$N_{i+1} = \left| \begin{matrix} N_X & N_L \\ D_X & D_L \end{matrix} \right|$$

I've shown this algorithm to a few lecturers at my uni and they don't know a name for it but suspect it is some sort of variation on the Euclidean Algorithm.

It can be used for divisibility tests (especially good in binary, if $$D_L = 1$$, or if $$D$$ is prime )

E.g. Does $$9734$$ divide by $$31$$

$$N_X = 973$$, $$N_L = 4$$

$$D_X=3$$, $$D_L = 1$$

$$N_0 = 9734$$

$$N_1 = \left| \begin{matrix} 973 & 4 \\ 3 & 1 \end{matrix} \right| = 961$$ $$N_2 = \left| \begin{matrix} 96 & 1 \\ 3 & 1 \end{matrix} \right| = 93$$ $$N_3 = \left| \begin{matrix} 9 & 3 \\ 3 & 1 \end{matrix} \right| = 0$$

If the algorithm hits $$0$$, then $$D|N$$ (Under certain conditions, counter example N=48, D=36)

Also, if $$D_L = 1$$ the quotient appears

$$N_1 = \left| \begin{matrix} 973 & \color{red}{4} \\ 3 & 1 \end{matrix} \right| = 961$$ $$N_2 = \left| \begin{matrix} 96 & \color{red}{1} \\ 3 & 1 \end{matrix} \right| = 93$$ $$N_3 = \left| \begin{matrix} 9 & \color{red}{3} \\ 3 & 1 \end{matrix} \right| = 0$$

$$9734 = \color{red}{314} \times 31$$

Any help is greatly appreciated! Thanks, Ben

• Did you have any luck finding a name for it? If you do I'd be grateful if you let me know. – Bill Dubuque Jan 19 at 17:28

It's the special case $$m = 10c\!+\!d,\ n = 10a\!+\!b\$$ of the following

$$\quad \bbox[5px,border:1px solid red]{(a,n) = 1\,\Rightarrow\, (m,n) = (am\!-\!cn,n)}\ \$$ by $$\,(m,n)=(am,n) = (am\!-\!cn,n)$$

So $$\ (a,b)=1\,\Rightarrow\, (10c\!+\!d,10a\!+\!b) = (ad\!-\!bc,10a\!+\!b),\$$ exactly as you observed.

Remark  Various well-known divisibity test rules are essentially special cases of this, e.g. the rule for divisibility by $$7$$ follows from the rule for $$21$$ given below (we negated $$\,ad\! -\! bc = 2d\!-\!c\,$$ below)

$$\qquad\qquad \qquad\ \ \ \, (10c\!+\!d,10(2)\!+\!1) = (c\!-\!2d, 10(2)\!+\!1)$$

$${\rm similar\ to\ your}\ \ (10c\!+\!d,10(3)\!+\!1) = (c\!-\!3d, 10(3)\!+\!1)\$$ rule for $$\,31$$

• Do you know if there is a name for it? Or how I might find other work on it? I've used it to do some cool things with Gaussian integers and I highly doubt I'm the first person to play with this idea! – Ben Crossley Jan 7 at 23:28
• @Ben I'm not aware of any common name for this. Things like this are folklore, e.g. occurring in various guises in divisibility tests. In number rings analogous results are often special cases of Hermite normal form algorithms for modules and related results, e.g. see here and here. If you give more details about your Gaussian integer results then I may be able to be more specific. – Bill Dubuque Jan 8 at 0:45
• @Ben By the way, another angle is to view $\,m = f(10)\,$ as a polynomial of degree $k$ in the radix. Then $$\bmod 10a\!+\!b\!:\,\ 10\equiv -b/a\,\Rightarrow\,(f(10),10a\!+\!b) = (a^kf(-b/a),10a\!+\!b)\qquad$$ and the algorithm can be viwed as a recursive scheme for evaluating $\,a^kf(-b/a)\,$ (a homogeneous polynomial in $\,a,b),\,$ analogous to Horner evaluation and related results. If this is of interest let me know and I can elaborate. – Bill Dubuque Jan 8 at 0:46