1

I have read the recursive divisibility test of number $n\in\mathbb{N}$ as $$f-Mr,$$ where $f$ are the front digits of $n$, $r$ is the rear digit of $n$ and $M$ is some multiplier. And I want to see if $n$ is divisible by some prime $p$. I saw that we need a method to work out the values of $M$.

I saw for a few examples $7,11,13,...,43,47,...$ that $M$ can be -2,+3,... .

I found on web that: "what you do is to calculate the smallest multiple of $p$ which ends in a $9$ or a $1$. If it's a $9$ we are going to ADD, then we will use the leading digit(s) of the multiple +1 as our multiplier M. If it's a 1 we are going to SUBTRACT later. then we will use the leading digit(s) of the multiple as our multiplier $M$."

For example, if we took $n=10f+r,p=7$ and $7|N$, then $$ -2N=-20f-2r \Rightarrow 21f-2N=f-2r \Rightarrow 7|f-2r. $$ So, what is the ideea of this algorithm, is there a general algebric proof? Why 1 or 9? Am I missing something obvious?

1 Answers1

1

$M$ can be easy determinated as follow: let $N=a_na_{n-1}...a_1a_0$ and we have $$ a_na_{n-1}...a_1a_0=10a_na_{n-1}...a_1+a_0=10\cdot a_na_{n-1}...a_1+10Ma_0+a_0(1-10M) $$ or, $mod\space p$, $$ 10M\equiv1(mod\space p). $$ So, here you just apply Euclid algorithm and is done: $$ M\equiv 10^{-1}(mod \space p). $$

teo
  • 166