1. This forum section is a read-only archive which contains old newsgroup posts. If you wish to post a query, please do so in one of our main forum sections (here). This way you will get a faster, better response from the members on Motherboard Point.

Re: A Puzzle for Today

Discussion in 'Embedded' started by Vladimir Vassilevsky, Apr 6, 2009.

  1. Tim Wescott wrote:

    > You have a Very Large Number, expressed as an binary integer, in the
    > memory of a machine that allows for byte-wide operations. For some
    > unfathomable reason, you need to determine if this number is evenly
    > divisible by 17.
    >
    > Without using long division or repeated subtraction, and without ever
    > performing a multiply or divide on a number greater than eight bits long,
    > how can you determine if your number is divisible by 17?
    >
    > Once you know this technique, what other potential divisors can you test
    > for using this method?


    That's simple: X must be (a << 4) + a; check the lowest byte.

    The magic numbers are 2^n +/- 1


    Vladimir Vassilevsky
    DSP and Mixed Signal Design Consultant
    http://www.abvolt.com
    Vladimir Vassilevsky, Apr 6, 2009
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. sk

    A puzzle to puzzle you

    sk, Jul 17, 2004, in forum: Hardware
    Replies:
    3
    Views:
    332
    jamotto
    Jul 18, 2004
  2. Jerry Avins

    Re: A Puzzle for Today

    Jerry Avins, Apr 6, 2009, in forum: Embedded
    Replies:
    2
    Views:
    264
    Jon Kirwan
    Apr 6, 2009
  3. Vladimir Vassilevsky

    Re: A Puzzle for Today

    Vladimir Vassilevsky, Apr 6, 2009, in forum: Embedded
    Replies:
    22
    Views:
    615
    Rocky
    Apr 22, 2009
  4. Jon Kirwan

    Re: A Puzzle for Today

    Jon Kirwan, Apr 6, 2009, in forum: Embedded
    Replies:
    2
    Views:
    265
    Jon Kirwan
    Apr 6, 2009
  5. Habib Bouaziz-Viallet

    Re: A Puzzle for Today

    Habib Bouaziz-Viallet, Apr 8, 2009, in forum: Embedded
    Replies:
    9
    Views:
    266
    Jerry Avins
    Apr 9, 2009
Loading...

Share This Page