Login or Sign Up to become a member!
LessThanDot Site Logo

LessThanDot

A Technical Community for IT Professionals

Less Than Dot is a community of passionate IT professionals and enthusiasts dedicated to sharing technical knowledge, experience, and assistance. Inside you will find reference materials, interesting technical discussions, and expert tips and commentary. Once you register for an account you will have immediate access to the forums and all past articles and commentaries.

LTD Social Sitings

Lessthandot twitter Lessthandot Linkedin Lessthandot facebook Lessthandot rss

Note: Watch for social icons on posts by your favorite authors to follow their postings on these and other social sites.

Highly Rated Users

Forum
No Posts Rated

Top 50
Given
Received

Forum Statistics

Users
Members:
1875
Members Online:
3
Guests Online:
85

Total Post History
Posts:
81446
Topics:
18714

7-Day Post History
New Posts:
0
New Topics:
0
Active Topics:
0

Our newest member
konam534As

Other

FAQ
All times are UTC [ DST ]

Google Ads

peasant multiplication

Mind Boggling Puzzles, to keep that grey matter in shape...
Forum rules
Always post answers in a "Hidecode" tag, so that others have a chance to answer the question too.
Please wait...

peasant multiplication

Postby phillip1882 on Fri Aug 05, 2011 5:34 pm

so i'd thought i'd add this as a point of interest.
there is an alternate way of multiplying 2 numbers, called peasant multiplication. i'll give an example.

96 * 54 = ?

so write 54 on a column, and 96 on the column below, on the left side.
  1.       54
  2.  96
  3.  

divide 54 by 2, and record the remainder.
  1.       54
  2.   96  27 r 0
  3.  

multiply 96 by 2. divide 27 by 2 and record the remainder.
  1.        54
  2.    96  27 r 0
  3.   192  13 r 1
  4.  

keep multiplying and dividing untill you get 0 for the division.
  1.        54
  2.    96  27 r 0
  3.   192  13 r 1
  4.   384   6 r 1
  5.   768   3 r 0
  6.  1536   1 r 1
  7.  3072   0 r 1
  8.  

then, for every row on the left that has a 1 on the right for remainder, add.
  1.    192
  2.    384
  3.   1536
  4.  +3072
  5. ------
  6.   5184
  7.  


this method works for any base, not just 2. here would be the same numbers, in balanced ternary.
  1.          54
  2.      96  18 r 0
  3.     288   6 r 0
  4.     864   2 r 0
  5.    2592   0 r 2 -
  6.    7776         +
  7.  
  8.   -2592
  9.   +7776
  10.  ------
  11.    5184
  12.  
User avatar
phillip1882
Apprentice
Apprentice
LTD Bronze - Rating: 22
 
Posts: 19
Joined: Mon Mar 14, 2011 11:05 pm
Location: florida

Re: peasant multiplication

Postby Thirster42 on Fri Aug 05, 2011 7:02 pm

so... are you wanting code implementations of this?
Ask three DBAs a question, and you’ll get four different answers.

-Brent Ozar
User avatar
Thirster42
Guru
Guru
LTD Silver - Rating: 517LTD Silver - Rating: 517LTD Silver - Rating: 517LTD Silver - Rating: 517LTD Silver - Rating: 517
LTD Silver - Rating: 517LTD Silver - Rating: 517LTD Silver - Rating: 517
 
Posts: 4646
Joined: Tue Nov 11, 2008 5:49 pm
Location: Jefferson City, Mo
Unrated

Re: peasant multiplication

Postby damber on Fri Aug 05, 2011 8:26 pm

Thirster42 wrote:so... are you wanting code implementations of this?


Why not write one anyway?
a smile is worth a thousand kind words, so smile, it's easy! :-)


CODE: $5
WORKING CODE: $500
PROPERLY DESIGNED & WORKING CODE: Priceless
User avatar
damber
LTD Admin
LTD Admin
LTD Silver - Rating: 663LTD Silver - Rating: 663LTD Silver - Rating: 663LTD Silver - Rating: 663LTD Silver - Rating: 663
LTD Silver - Rating: 663LTD Silver - Rating: 663LTD Silver - Rating: 663LTD Silver - Rating: 663LTD Silver - Rating: 663
 
Posts: 3138
Joined: Tue Oct 09, 2007 1:48 pm
Location: North Wales, UK
Unrated

Re: peasant multiplication

Postby Thirster42 on Fri Aug 05, 2011 8:42 pm

damber wrote:
Thirster42 wrote:so... are you wanting code implementations of this?


Why not write one anyway?


well fine then!

Code is hidden, SHOW
Ask three DBAs a question, and you’ll get four different answers.

-Brent Ozar
User avatar
Thirster42
Guru
Guru
LTD Silver - Rating: 517LTD Silver - Rating: 517LTD Silver - Rating: 517LTD Silver - Rating: 517LTD Silver - Rating: 517
LTD Silver - Rating: 517LTD Silver - Rating: 517LTD Silver - Rating: 517
 
Posts: 4646
Joined: Tue Nov 11, 2008 5:49 pm
Location: Jefferson City, Mo

Re: peasant multiplication

Postby chrissie1 on Sat Aug 06, 2011 3:04 pm

My unittest

Code is hidden, SHOW


and my ruby code

Code is hidden, SHOW
pink fuzzy slippers
User avatar
chrissie1
Senior Guru
Senior Guru
LTD Gold - Rating: 2135LTD Gold - Rating: 2135LTD Gold - Rating: 2135LTD Gold - Rating: 2135LTD Gold - Rating: 2135
LTD Gold - Rating: 2135LTD Gold - Rating: 2135LTD Gold - Rating: 2135LTD Gold - Rating: 2135LTD Gold - Rating: 2135
LTD Gold - Rating: 2135LTD Gold - Rating: 2135
 
Posts: 9475
Joined: Wed Oct 10, 2007 7:18 pm
Location: Belgium
Unrated