Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
If we do not hit our goal we will be forced to close the site.

Current status: https://keepboardsalive.com/

Annual subs are best for most impact. If you are still undecided on going Ad Free - you can also donate using the Paypal Donate option. All contribution helps. Thank you.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.

How does this work, division by 7

  • 08-04-2009 05:16PM
    #1
    Registered Users, Registered Users 2 Posts: 111 ✭✭


    Can any one help me?
    I have an algorithm which shows if a number is divisible by 7. It works like this:

    To determine if a number is divisible by 7, take the last digit off the number, double it and subtract the doubled number from the remaining number. If the result is evenly divisible by 7 (e.g. 14, 7, 0, -7, etc.), then the number is divisible by seven. This may need to be repeated several times.

    Is 3101 evenly divisible by 7?

    Take off the last digit = 310
    double and subtract -2
    308
    Take off the last digit = 30
    double and subtract -16
    answer 14 divisible by 7 so so is 3101

    And it works, at least I can’t find a counter example, but I can’t figure out why it works, does anyone know.


Comments

  • Registered Users, Registered Users 2 Posts: 48 timbrophy


    It works because the sequence of operations preserves divisibility by 7. Suppose you have the number represented by the string of digits "abcde". Call this number n. Then
    n = a*10^4 + b*10^3 + c*10^2 + d*10 + e
    Take off the last digit to get a*10^3 + b*10^2 + c*10 + d
    Subtract 2e to get a*10^3 + b*10^2 + (c*10 + d - 2e)
    If this is divisible by 7 we have
    a*10^3 + b*10^2 + c*10 + d -2e = 0 mod 7
    so multiplying by 10 we get
    a*10^4 + b*10^3 + c*10^2 + d*10 - 20e = 0 mod 7
    add 21e to both sides to get
    a*10^4 + b*10^3 + c*10^2 + d*10 + e = 21e mod 7
    which is just
    n = 0 mod 7 since 21 is a multiple of 7

    As you can see, the only digits that matter are c, d and e so this method will always work.


  • Registered Users, Registered Users 2 Posts: 111 ✭✭getting worse


    Thanks tim


  • Closed Accounts Posts: 224 ✭✭Cheeble


    What's the property of 7 that causes this:

    1/7=0.142857 all 6 digits recurring i.e. 1/7=0.142857142857142.....
    2/7=0.285714 ditto
    3/7=0.428571 ditto
    4/7=0.571428 ditto
    5/7=0.714285 ditto
    6/7=0.857142 ditto

    i.e. if you can remember the six digit sequence (it's the same in each case), you can divide by 7 just by starting with the right digit.

    Cheeble-eers


  • Registered Users, Registered Users 2 Posts: 870 ✭✭✭overmantle


    Nothing like a post like this to get the old brain out of neutral! Well done.


  • Registered Users, Registered Users 2 Posts: 1,595 ✭✭✭MathsManiac


    Cheeble wrote: »
    What's the property of 7 that causes this:

    The fact that 10 is a primitive root modulo 7.

    (This also works, for example, for 17, 19, 23, 29, 47, and many more.)

    Here's an interesting and related question: for any whole number n, what is the length of the repeating cycle in the recurring decimal expansion of 1/n?

    (Hint: try prime n first. And looking it up in Wikipedia is cheating!)


  • Advertisement
  • Registered Users, Registered Users 2 Posts: 48 timbrophy


    (Hint: try prime n first. And looking it up in Wikipedia is cheating!)

    After you try for a while look at
    http://mathworld.wolfram.com/DecimalExpansion.html
    which is fascinating.

    Tim


Advertisement