Motherboard Forums


Reply
Thread Tools Display Modes

Re: A Puzzle for Today

 
 
Vladimir Vassilevsky
Guest
Posts: n/a
 
      04-05-2009, 11:43 PM


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
 
Reply With Quote
 
 
 
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: A Puzzle for Today Vladimir Vassilevsky Embedded 22 04-22-2009 02:20 PM
Re: A Puzzle for Today Habib Bouaziz-Viallet Embedded 9 04-09-2009 10:15 PM
Re: A Puzzle for Today Jon Kirwan Embedded 2 04-06-2009 06:45 AM
Re: A Puzzle for Today Jerry Avins Embedded 2 04-06-2009 04:56 AM
A puzzle to puzzle you sk Hardware 3 07-18-2004 02:50 AM


All times are GMT. The time now is 11:54 PM.


Welcome!
Welcome to Motherboard Point
 

Advertisment