This is not stupid.
I am an electronic technician by training (not by trade it's a hobby now).
Put number "a" into a shift register.
Do the same with number "b".
Set a b pointer to look at the right most bit of b
     loop start
         If b pointer points to a zero
             do nothing
         If b pointer points to a one
              add a to the accumulator
If b pointer does not point to the left most bit
   shift b pointer and  "a" left  and go to loop start
If b pointer points to the left most bit read the accumulator

If a=3 and b=5 then a=11 b=101
first loop a=3 b will add 3 to the accumulator (because of the right hand
one)
second loop a=6 b will not add 6 to the accumulator (because of the zero)
third loop a=12 b will add 12 to the accumulator (because of the left hand
one)
the accumulator has 3+12 which equals 15 which equals 3*5.

You just took the specific case of a=b
-----Original Message-----
From: Jeremy Blosser <[EMAIL PROTECTED]>
To: Mesenne Mailing List (E-mail) <[EMAIL PROTECTED]>
Date: Friday, February 11, 2000 1:42 PM
Subject: Mersenne: Where's the flaw in my thinking?


>Okay, I was sitting there the other day thinking about a non-FFT squaring
>algorithm...
>
>Say we have 14, which in binary is 1110...
>
>If we left shift this by the position of the 1, for each 1 in the binary
>representation, and add them together, we should get the square... So to
>square 14, we do this:
>1110 << 3 == 1110000 +
>1110 << 2 == 0111000 +
>1110 << 1 == 0011100 +
> == 11000100 which is 196
>
>So for each squaring, we have x left shifts and adds, where x is no larger
>that p.
>
>In any case... is this just me being dumb and missing that this is just a
>stupid way of squaring a number?
>_________________________________________________________________
>Unsubscribe & list info -- http://www.scruz.net/~luke/signup.htm
>Mersenne Prime FAQ      -- http://www.tasam.com/~lrwiman/FAQ-mers



_________________________________________________________________
Unsubscribe & list info -- http://www.scruz.net/~luke/signup.htm
Mersenne Prime FAQ      -- http://www.tasam.com/~lrwiman/FAQ-mers

Reply via email to