Wednesday, September 25, 2024

Minor amusement

I know I should use the time walking laps more productively, but I find it hard to compose in my head: I start a scene, but keep circling back to the beginning. Praying gets distracted too. So. Factoring numbers, anybody?

Everybody knows how to check if (in base 10) a number is divisible by 3: just add the digits, and if the sum is divisible by 3, so is the original. 9 is easy too: just add the digits, and if the sum is divisible by 9, so is the original. 2 is easy: is the right-most digit even? 5 is easy: is the right-most digit 0 or 5? 4 and 8 are easy to do sequentially, or you can look at the last two digits: if divisible by 4, the whole number is. The last 3: if divisible by 8, the whole number is.

Ah, but 7? Hmm. (Spoiler; there's a simple way to check, but I didn't know it then.)

If we've a number k whose digits are $N_n N_{n-1}...N_2 N_1 N_0$, where $N_0$ is the units digit, $N_1$ the 10's, and so on, we can write this as $\sum_i N_i 10^i$. That's trivial. Suppose we divide by 3, but divide each of the $10^i$ terms. For $i=0$ (i.e. 1), we have 0 R1. For $i=1$ we have 3R1, then 33R1, 333R1, etc. Now we have two parts: $\sum_i N_i 33..3$ (a nice integer) and a remainder of $\sum_i N_i (1) / 3$. The leftover part, the sum over the digits, determines whether the number is divisible by 3. OK, that's pretty simple, and proves that the old rule, which we knew already.

Dividing by 9 works the same way, except that the integer part after dividing by 9 is $\sum_i N_i 11..1$ with 1's instead of 3's. The remainders are also 1, just as before and the remainder term is also a sum of the digits, divided by 9.

How about 7?

i$10^i$integerremainder
0101
11013
2100142
310001426
41000014284
5100000142855
610000001428571
etc

So, If you create the sum $1 N_0 + 3 N_1 + 2 N_2 + 6 N_3 ...$, if the sum is divisible by 7, so is the original number.

Granted, it's not as nice as the simple digit sum, but it works.

Before you ask, no, I only worked out the sketch of this on the track. I need pen and paper as much as the next person.

For those who have been snickering, yes, I looked this up and found the easy way too.

One way to think about the problem is to note that if you think of dividing the number into all the digits except the units digit, and the units digit, there'll only be 1 or 2 possibilities for the units digit for which the whole is divisible by 7. So maybe breaking the number up that way would be productive; maybe there's a simple relationship.

$k = 10 \times A + B$, where $B$ is a single digit. Now noodle around a bit: multiply by $5$. $5 \times k = 50 \times A + 5 \times B = 49 \times A + A + 5 \times B$. Part of that is obviously divisible by 7, so if $A + 5 \times B$ is divisible by 7, the original number is also. E.g. 4627 $4627 = 10{\times}462 + 7$, so $A=462$ and $B=7$. The formula says $462 + 5 \times 7 = 497$. Inspection says that's divisible by 7, so the original was too. Obviously you can use the formula $A - 2B$ as well. You'll find both easily on search engines.

Suppose we wanted to find a similar formula to tell us about 11. We need 2 digits for $B$, so we rewrite our number $k$ as $100 \times A + B$. Looking closer we see $100 \times A + B = 99 \times A + A + B$. Since 99 is already divisible by 11, we immediately see that if $A + B$ is divisible by 11, so is the original number. Check 7271: $72 + 71 = 143$, which is $11 \times 13$.

For 13, it isn't hard to see that $A + 3 \times B$ works: try it with 8593.

No doubt there are tables of these simple tricks somewhere

Yes, the church nursery posts a number in the sanctuary if a parent needs to come see to their child. And yes, I try to factor it.

3 comments:

Assistant Village Idiot said...

You have seen the Trachtenberg System? https://en.wikipedia.org/wiki/Trachtenberg_system

Assistant Village Idiot said...

Back in the days of 5-digit odometers, when driving on the highway I would try to factor a number before the mile changed. It is usually doable, but harder, with 6 digits. I no longer bother.

james said...

No, I've heard of Trachtenberg but never looked it up before.