Thursday, May 10, 2018

Divisibility - A more general approach
Niranjan Ramakrishnan
May 8, 2018

Everyone is taught some basic rules for checking if a number is divisible by 2, 3, 4, 5, etc . Any even number is divisible by 2. For 3, if the sum of its digits is divisible by 3, so is the number itself. If the number formed by its last two digits can be divided clean by 4, the number is divisible by 4. Any number ending in either a zero or a 5 is divisible by 5. Any An even number divisible by 3 is divisible by 6. The rule for 8 is similar to that for 4, except that the number tested is that formed by the last three digits - not the last two. The rule for 9 is identical to that for 3 - if the sum of the digits is divisible by 9, so is the number. The test for 10 is trivial - any number ending in a 0. One other rule is taught: if total of the odd positioned and even-positioned digits is either equal or differs by a multiple of 11, the number is divisible by 11.

If still awake a reader might notice that the rules summary is missing any mention of 7. This is because in teaching rules of divisibility the number 7 stood in some bad odor, unamenable to  ready rulemaking. We used to declare, as our elders nodded mournfully, that there was no rule for 7.

But there does exist a divisibility rule for 7, as I learned from the Internet some years ago. Yesterday I stumbled on the fact that the rule for 7 contains an approach that blows open a path to check divisibility more general than the techniques we were taught.

Let's start with the divisibility formula for 7. First some definitions. Three concepts are involved. The number being tested is broken into two parts - the last digit, the number in the units or 1's place, which we shall call 'u', and the rest of the original number, which we shall call, 'r'. That's two of the three concepts.

E.g., if our number is 266, u=6 and r=26.
The algorithm for7 is as follows: if r-2*u is divisible by 7, then so is the original number.
Applying this to 266, r-2*u = 26-2*6 = 26-12 = 14
Since 14 is divisible by 7, so is 266 (7 times 38).
Note that a subtraction result of 0 also means the number is divisible, as zero is divisible by 7 (or by any Natural number).
E.g., 84. r=8, u=4. r-2*u gives 0.

The third concept is the multiplier 'm', 2 in this algorithm for 7. How exactly 'm' is to be calculated will be discussed shortly.
 
I rested content in this knowledge until yesterday, when a sudden email arrived from my sister, comprising a single line, "What is the formula for divisibility by 17?"

I didn't know, of course. Wondering if there wasn't something for 17 along the lines of the formula for 7, I  began to explore in my mind various combinations and to my surprise chanced upon one which seemed to work. All that was required was to use 5 as the multiplier in place of 2. Thus for 17 itself, r=1, u=7,m=5, and r-m*u = -34. For 102, 10-5*2= 0!

This success emboldened me look at 27, and I found that a multiplier of 8 worked beautifully. It seemed to be a series - 2(7), 5(17) 8(27), 11(37), 14(47), etc. in short, m=3x+2, where x is 0 for 7, 1 for 17, 2 for 27, 3 for 37,...25 for 257, etc.

Next I tackled 13, the next prime number without a divisibility formula (that I knew of). Turned out to have one, but of the form r + m * u, i.e., a plus instead of a minus. For 13, m=4. For 23 m= 7, etc. the general expression being m=3x+1, where x is 0 for 3, 1 for 13, 2 for 23, ...25 for 253, etc.

Then for numbers ending in 9, the formula is m=x+1, where x is again 0 for 9, 1 for 19,... 25 for 259, etc.  We have to check r+m*u,  just like for numbers ending in 3.

Finally,  numbers that end in 1. Here, m=x,  where x is 0 for 1, 1 for 11, 2 for 21, 3 for 31,... 25 for 251, etc.  The number to test is r-m*u.

Deciding to press my luck I ventured into numbers ending in 5. No obvious pattern suggested itself.

But there is an alternating pattern to the four number-endings,.  1 (r-m*u),  3 (r+m*u),  7 (r-m*u)  and 9 (r+m*u).

I'm sure students of mathematics are familiar with these formulas,  but I certainly hadn't encountered rules for 7, 13, 19, etc.  during my several years of science and mathematics in school and college,  which is why the utter simplicity - and generality -  brought so much delight when I uncovered them.

One example each of divisors ending in 1, 3, 7 and 9.

Is 372 divisible by 31?
Formula: r-m*u and m=x.
Here,  r=37, u=2, m(=x)=3.
r-m*u = 37-2*3 = 37-6  = 31. Divisible!

Is 559 divisible by 43?
Formula: r+m*u,  where m=3x+1.
Here,  r=55,  u=9, m(3x+1)=13.
r+m*u = 55+13*9 = 55+117 = 172. 172 = 4 * 43. Divisible!

Is 1164 divisible by 97?
Formula: r-m*u,  where m=3x+2.
Here,  r=116, u=4,m(3x+2)=29.
r-m*u = 116-29*4 = 116-116 = 0. Divisible!

 Is 1157 divisible by 89?
Formula: r+m*u,  where m=x+1.
Here, r=115, u=7, m(x+1)=9.
r+m*u = 115+9*7 = 115+63 = 178. 178 is 2 times 89. Divisible!

2 comments:

Mosur Mohan said...

Interesting indeed, Niranjan! I finally got some time to browse this post, though I didn't work my way through all the details.
One thought that I still haven't followed through fully on: the original purpose of these rules was to compute divisibility at a fraction of the cost of doing the actual division. Now, especially with the larger divisors, how should we determine whether the rule is cheap enough?

Cheers,
Mohan

Gidu Sriram said...

Niranjan, I finally found time to read this and it blew my mind. I was thrilled to just follow along and understand everything that you had come up with. I can't imagine what joy this would have brought you to come up with it. How can we share this in the Mathematical forum? This might be some kind of discovery which needs to be recorded somewhere. I will forward this to Prof. Krishnamurthy who was a Mathematics Professor at BITS Pilani. Congratulations Niranjan!