RosettaCodeData/Task/Ethiopian-multiplication/00DESCRIPTION
2016-12-05 22:15:40 +01:00

59 lines
2.2 KiB
Text

Ethiopian multiplication is a method of multiplying integers using only addition, doubling, and halving.
'''Method:''' <br>
# Take two numbers to be multiplied and write them down at the top of two columns.
# In the left-hand column repeatedly halve the last number, discarding any remainders, and write the result below the last in the same column, until you write a value of 1.
# In the right-hand column repeatedly double the last number and write the result below. stop when you add a result in the same row as where the left hand column shows 1.
# Examine the table produced and discard any row where the value in the left column is even.
# Sum the values in the right-hand column that remain to produce the result of multiplying the original two numbers together
<br>
'''For example:''' &nbsp; 17 &times; 34
17 34
Halving the first column:
17 34
8
4
2
1
Doubling the second column:
17 34
8 68
4 136
2 272
1 544
Strike-out rows whose first cell is even:
17 34
8 <strike>68</strike>
4 <strike>136</strike>
2 <strike>272</strike>
1 544
Sum the remaining numbers in the right-hand column:
17 34
8 --
4 ---
2 ---
1 544
====
578
So 17 multiplied by 34, by the Ethiopian method is 578.
;Task:
The task is to '''define three named functions'''/methods/procedures/subroutines:
# one to '''halve an integer''',
# one to '''double an integer''', and
# one to '''state if an integer is even'''.
<br>
Use these functions to '''create a function that does Ethiopian multiplication'''.
;References:
*[http://www.bbc.co.uk/learningzone/clips/ethiopian-multiplication-explained/11232.html Ethiopian multiplication explained] (Video)
*[http://www.youtube.com/watch?v=Nc4yrFXw20Q A Night Of Numbers - Go Forth And Multiply] (Video)
*[http://www.ncetm.org.uk/blogs/3064 Ethiopian multiplication]
*[http://www.bbc.co.uk/dna/h2g2/A22808126 Russian Peasant Multiplication]
*[http://thedailywtf.com/Articles/Programming-Praxis-Russian-Peasant-Multiplication.aspx Programming Praxis: Russian Peasant Multiplication]
<br><br>