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?