Friday, December 13, 2013

Division by seven

So first up a justification for why I would want to write about dividing by seven. The short answer is that dividing by any of one through six is pretty trivial. Dividing by two ,three, four, five or six is straight forward primary school mathematics.  Dividing by one is appropriate for (insert group you’d like to insult here).  Seven is the first interesting case.  Long answer: Read the rest of this post and hopefully you’ll see.  Advertising answer: It’s fun to be able to rattle off 20 or 30 digits easily (also cheap and obnoxious but still fun), in front of people who don’t know how to do this.
Long ago in the dim reaches of grade five or so (in my case it was still called standard three) we learned short division.  For those of you who don’t remember grade five (or haven’t gotten there yet). I’ll outline how this works below. Suppose I want to divide 629 by 4. (Obviously skip this if know it).
Start out by writing

I can’t divide this all in my head but I do know that 4 goes into the first digit (6 in this case)  once and leaves a remainder of 2. So I write.

The next step is noticing that 4 goes into  22, five times and leaves a remainder of 2. So I write

Repeating this procedure a few more times (and adding in some zeros after the decimal point) gives us.

Which is to say that 629 divided by 4 is 157.25.

The refresher out of the way let’s try to divide 1 by 7. Start here.

Now fill in some of the rest of it (actually do it if you haven’t).
You’ll get this after 6 iterations.

From here we notice, that we’re pretty much where we started.
We have to divide 10 by 7 in both of the previous 2 pictures and we have an infinite string of 0s in front of us. So we’re going to get the same thing over and over and over again!!!

So 1/7=0.14285714285714285714285714…….
Just remember those six digits in order (less than a phone number and you remember yours) and you can pull off the trick of dividing one by seven.
It gets better though. Dividing two by seven is just as easy, in fact we have already done it!!
How you ask. Well start here

We’ve been here before? Dividing 20 by seven. We get the SAME repeating decimal with a different start point (not to beat anyone over the head with anything but yeah,3/7, 4/7,5/7 and 6/7 work the same way).

All you need to do is remember your start point (and the 6 digit string 142857) and you can divide by 7.
If you want to divide say 27 by 7 then. 27/7=3 remainder 6 so 3.857142857…..
This a pretty neat trick but even better there really isn’t anything special about 7. Provided we're willing to learna 16 digit string we can do division by 17. Division by 13 requires learing two 6 digit strings

This works for every positive integer which doesn’t have 2 or 5 as a factor (why 2 and 5 because they are 10s prime factors  and we're using base 10, yes this also works in every other base for exactly the same reasons). 

For example consider dividing 1 by 349. There are only 348 possible things to carry over when dividing 1 by 349  so when I go through the procedure of short division I’m guaranteed to get back to 1 (the first thing I carry) in at most 348 steps and things will repeat.  The period might not be 348 but it won’t be more.  For example the next 2 “interest numbers”  to divide by in base 10 are 13 and 17.
This is of length 16 and provided you can remember where to start you can figure out k/17 for pretty much any integer k. On the other hand
1/13=0.0769230769230769230… has period 6. So it only gets half of the the k/13s you could wish for.
2/13=0.153846153846…. also has period 6 and gets us the other half.
So when do we get everything from just 1 cycle??? The answer comes oddly enough from geometric series.

To see this we'll consider some examples.
Giving us 7*142857=999999.
Same thing goes through with 13. What this means is that
i.e. 13*076923=999999
The only way to have a period of length (a factor of) 6 is to be divisible by 10^6-1.

Clearly 17 does divide 10^16 - 1 but none of 10^8 - 1, 10^4 - 1, 10^2 - 1 and 10^1 - 1. So it’s period is actually 16.
There are other ways to think about this and it’s quite abit of fun to do so. But this post is getting long so I’ll stop here. 


  1. Maybe a silly question, but what's an efficient way to determine the period of 1/n in base 10?

    I realize that the period of 1/n is k implies that 10^k = 1 (mod n), but I'm not sure how to cleanly find the smallest k for which this is true.

  2. "If you want to divide say 27 by 7 then. 27/7=3 remainder 6 so 3.857142857….."

    Okay, sure, but first you need to get that 27/7 is 3 remainder 6, which is the real meat of the division. This just lets you turn the "remainder" bit into a string of digits, which is neat I guess but doesn't do you a lot of good if you're trying to divide a four-digit number by 7. I dunno, from the post title I guess I was expecting a neat divisibility trick for 7 or something.

    1. Ok so if you want to test for divisibility by 7 then you can cut off the units coloum and subtract it from the other bit twice.
      example to see if 123456 is divisible y 7

      123456 goes to
      12345-2*6=12333 goes to
      1233-2*3=1227 goes to
      122-2*7= 108 which isn't divisible by 7 so 123456 isn't either

    2. Ooh, clever. You're basically subtracting 21 times the units digit from the original number, then dividing the result by 10. Since 7|21 and 10 is coprime to 21, that works. Presumably you could extend this to other divisors, e.g. subtract the units digit 5 times instead of 2 times to test divisibility by 17? (Though 17's pretty easy anyhow because it divides 102 and 1003.)

    3. I like that way of thinking about it. I guess we need a multiple of 17 which ends in 1 so, cut off last digit and subtract 5 times that from the non-units part?

  3. M(¹³)+A(¹)+T(²ยบ)+H(8)=42db(Date of Birth)

    The result of the math literary equals the last number 4•2=8HeArt or h8.

    Also the numbers 42 mirror is 24(x) for the hours of day(times).

    This number is also found in the Magikal Sun Table.