1

Context

Let me start by saying that I did this many years ago so I don't remember how I got there.

I was reviewing some old notes I wrote in August $2017$ in which I had written this algorithm to calculate the divisibility criterion of a generic prime number.

My work

I wrote this:
A number is divisible by a prime number $n$ if the sum/difference of the prenumber $p$ and $k$ times the units digit $u$ is a multiple of $n$

The prenumber is the number without the unit: (the prenumber of $1028$ is $102$)

$$\begin{array}{|c|c|c|c|c|c|}\hline n&p+k u&p-k u&n&p+k u&p-k u\\\hline 7&p+5u&p-2u&47&p+33u&p-14u\\\hline 11&p+10u&p-u&53&p+16u&p-37u\\\hline 13&p+4u&p-9u&59&p+6u&p-53u\\\hline 17&p+12u&p-5u&61&p+55u&p-6u\\\hline 19&p+2u&p-17u&67&p+47u&p-20u\\\hline 23&p+7u&p-16u&71&p+64u&p-7u\\\hline 29&p+3u&p-26u&73&p+22u&p-51u\\\hline 31&p+28u&p-3u&79&p+8u&p-71u\\\hline 37&p+26u&p-11u&83&p+25u&p-58u\\\hline 41&p+37u&p-4u&89&p+9u&p-80u\\\hline 43&p+13u&p-30u&97&p+68u&p-29u\\\hline \end{array}$$ Where $k$ it is calculated based on the units $u$: $$k=\begin{cases}9p+1\ \wedge\ -p&\text{if }u=1\\3p+1\ \wedge\ -7p-2&\text{if }u=3\\7p+5\ \wedge\ -3p-2&\text{if }u=7\\\ \ p+1\ \wedge\ -9p-8&\text{if }u=9\end{cases}$$

Example 1

Let's check that $623$ is divisible by $89$.
Its prenumber is $p=62$ and $u=3$.
Taking the value in the table (I'll take the positive one): $k=9$
So substituting the values:
$p+ku=62+9\cdot 3=89$ which, trivially, is divisible by $89$, so $623$ is divisible by $89$

Example 2

Let's check that $1241$ is divisible by $73$.
Its prenumber is $p=124$ and $u=1$.
Taking the value in the table (I'll take the negative one): $k=-51$
$p+ku=124-51\cdot 1\cdot 1=73$ which, trivially again, is divisible by $73$, so $1241$ is divisible by $73$

Example 3

Let's check that $4171$ is divisible by $97$.
Its prenumber is $p=417$ and $u=1$.
Taking the value in the table (I'll take the negative one): $k=-29$
$p+ku=417-29\cdot 1=388$, which is divisible by $97$ ($388=94\cdot 4$), so $4171$ is divisibile by $97$

Example 4

Let's check that $943$ is divisible by $29$.
Its prenumber is $p=94$ and $u=3$.
Taking the value in the table (I'll take the positive one): $k=3$
$p+ku=94+3\cdot 3=103$, which is not divisible by $29$ ($103$ is a prime number), so $943$ is not divisibile by $29$

Question

I specify that I have never demonstrated this and right now I wouldn't be able to, I wanted to know if this algorithm already existed and had a name (and if so, does it have a demonstration).

Bill Dubuque
  • 272,048
  • What do the lines $k=9p+1\wedge k=-p\quad u=1$ etc. mean? In your first example, $p=62$ and $u=3$ and $k=9$ does not match any of these cases. -- I suppose, you rather want $k$ to depend only on $n$. In fact, the result follows by picking $k$ such that $10k\equiv 1\pmod n$. – Hagen von Eitzen Jan 07 '24 at 17:32
  • @HagenvonEitzen is the algorithm for calculating the various $k$. For example for $n=29$ you have that $p=2$ and $u=9$, therefore $k=p+1=3$ and $k=-9p-8=-26$) – Math Attack Jan 07 '24 at 17:36
  • Special cases of this Theorem in the linked dupe (which is well known). – Bill Dubuque Jan 07 '24 at 19:08
  • Note that for a solution-verification question to be on topic you must specify precisely which step in the proof you question, and why so. This site is not meant to be used as a proof checking machine. – Bill Dubuque Jan 07 '24 at 19:09

1 Answers1

2

Exclude $2,5$ from your primes.

Fix a prime $q$.

Then we can solve the linear congruence $10\times k\equiv 1 \pmod q$.

For instance, if $q=89$, then we could take $k=9$.

Now, say your candidate number is $A=\overline {a_na_{n-1}\cdots a_0}$ so, in your notation, $u=a_0$ and $p$, the "prenumber", is $\frac { A-a_0}{10}$.

Thus, $\pmod q$, we have $$p\equiv kA-ka_0\pmod q$$

It follows that $$p+ka_0\equiv kA\pmod q$$ so we quickly see that $q\,|\,A$ if and only if $q\,|\,(p+ka_0)$ as desired.

Note that your given forms support this pattern. With $q=17$, for instance, we remark that $10\times 12\equiv 1\pmod {17}$ and so on. A similar analysis applies to the negative case (note that your positive and negative coefficients sum to $q$).

Note too that the claim is false for $q\in \{2,5\}$. Indeed $10$ is divisible by both $2,5$ but there is no $k$ such that $1+k\times 0$ is divisible by either.

lulu
  • 70,402
  • Uh awesome, do you even know if this thing has a name? (I would like to write it down as a reference on the notes) – Math Attack Jan 07 '24 at 17:43
  • I wouldn't think that this had a name...it's not clear that it's all that useful, unfortunately. To use it, you have to invert $10\pmod q$ and even then, you still have a number which is only one digit shorter than the original one. Meanwhile, just doing the division isn't that bad. – lulu Jan 07 '24 at 17:47
  • Please strive not to post more (dupe) answers to dupes of FAQs. This is enforced site policy, see here. – Bill Dubuque Jan 07 '24 at 19:08