HP3000-L Archives

December 2000, Week 1

HP3000-L@RAVEN.UTC.EDU

Options: Use Monospaced Font
Show Text Part by Default
Show All Mail Headers

Message: [<< First] [< Prev] [Next >] [Last >>]
Topic: [<< First] [< Prev] [Next >] [Last >>]
Author: [<< First] [< Prev] [Next >] [Last >>]

Print Reply
Subject:
From:
Reply To:
Ted Ashton <[log in to unmask]>
Date:
Fri, 1 Dec 2000 14:28:20 -0500
Content-Type:
text/plain
Parts/Attachments:
text/plain (57 lines)
Thus it was written in the epistle of Porter, Allen H,
> OK, I'm trying to figure this out but I cannot remember how to do the math
> behind it.
>
> If I have a series such as
> 1
> 2
> 4
> 8
> 16
> 32
> 64
> 128
>
> and I add any combination of these numbers together (4 + 16 = 20) the only
> way I can come up with the number 20 is by adding 4 and 16.  Now how do I do
> this in reverse?  If I know the sum is 81, how do I determine that the
> numbers that make up this sum are 1 + 16 + 64?
>
> Thanks to anyone with the solution.

As you've already heard the typical solution, here's another one for the
amusement of it:

Take your number, divide by 2 repeatedly until you reach 0, writing down the
remainders.  Simultaneously, write down the successive powers of two:

   81 / 2 = 40 r 1     1
   40 / 2 = 20         2
   20 / 2 = 10         4
   10 / 2 =  5         8
    5 / 2 =  2 r 1    16
    2 / 2 =  1        32
    1 / 2 =  0 r 1    64

In the cases where there are remainders, multiply the remainders by the
associated power of two and you have the desired 1 + 16 + 64.  This will
also work for other powers:

  81 / 5 = 16 r 1      1
  16 / 5 =  3 r 1      5
   3 / 5 =  0 r 3     25

giving 81 = 1 + 5 + 75

Oddly enough, there are times when going at it "backwards" like this is
preferable.

Ted
--
Ted Ashton ([log in to unmask]), Info Sys, Southern Adventist University
          ==========================================================
Men pass away, but their deeds abide.
                                        -- Cauchy, Augustin-Louis (1789 - 1857)
          ==========================================================
         Deep thoughts to be found at http://www.southern.edu/~ashted

ATOM RSS1 RSS2