Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.soft-sys.math.mathematica > #15076
| From | Bob Hanlon <hanlonr357@gmail.com> |
|---|---|
| Newsgroups | comp.soft-sys.math.mathematica |
| Subject | Re: Russian Peasant Multiplication / was question on |
| Date | 2013-07-01 09:45 +0000 |
| Message-ID | <kqrj3p$4bl$1@smc.vnet.net> (permalink) |
| References | <kqm6u7$hp5$1@smc.vnet.net> |
| Organization | Time-Warner Telecom |
Clear[russianPeasantMultiply];
russianPeasantMultiply[
x_Integer, y_Integer] :=
Sign[x]*Sign[y]*
Total[
Cases[
NestWhileList[
Floor[{1/2, 2}*#] &,
Sort[Abs[{x, y}]],
(First[#] > 1) &],
{_?OddQ, _}][[All, -1]]];
m = 10^6;
x = RandomInteger[{-m, m}];
y = RandomInteger[{-m, m}];
russianPeasantMultiply[x, y] == x*y
True
Bob Hanlon
On Sun, Jun 30, 2013 at 3:29 AM, <d.a.paxton@gmail.com> wrote:
> On Saturday, June 29, 2013 2:47:03 AM UTC-6, Richard Fateman wrote:
> > Dave --
> >
> > 1. You should try to come up with a useful subject line
> >
> > in the future.
> >
> > 2. It is called Russian Peasant Multiplication (which you may
> >
> > find on Google).
> >
> > 3. There is no reason to believe that a procedural algorithm
> >
> > has a formula, but in this case I think the inverse is known
> >
> > as division :)
>
> I am sorry for posting a question that is improper. It is a matter of
> rounding as a floor or ceiling question I guess wondering nomenclature. If
> the lowest count on the numbers in a multiply are let's say 7 and 5. We
> multiple these and get 35. How does on drop the 5 into the lowest of the
> answer and carry the 3? Since 7 and 5 and also 35 are know known we do
> this.. In base ten we multiply by ten. Divide out the seven and get
> fifty. Divide that by ten and get the 5 drop out number. Then put the the
> thirty five minus the drop out number and then divide by ten again. Gives
> three. The carry number. So I guess in using this for any base number
> system we do have a divide as an inverse function for any variables in the
> course of a multiply.
>
>
Back to comp.soft-sys.math.mathematica | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Russian Peasant Multiplication / was question on how to do this Richard Fateman <fateman@cs.berkeley.edu> - 2013-06-29 08:47 +0000 Re: Russian Peasant Multiplication / was question on how to do this d.a.paxton@gmail.com - 2013-06-30 07:26 +0000 Re: Russian Peasant Multiplication / was question on Bob Hanlon <hanlonr357@gmail.com> - 2013-07-01 09:45 +0000 Re: Russian Peasant Multiplication / was question on how to do this d.a.paxton@gmail.com - 2013-07-02 04:35 +0000 Re: Russian Peasant Multiplication / was question on James Stein <mathgroup@stein.org> - 2013-07-03 08:47 +0000 Re: Russian Peasant Multiplication / was question on how to do this d.a.paxton@gmail.com - 2013-07-03 08:50 +0000 Re: Russian Peasant Multiplication / was question on Bob Hanlon <hanlonr357@gmail.com> - 2013-07-03 08:53 +0000
csiph-web