Ethiopian multiplication: Difference between revisions

Content added Content deleted
m (→‎{{header|Tcl}}: closer match with varnames from other examples)
m (Formatting of header material)
Line 3:
 
'''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><br>
 
'''For example:''' 17 x 34
 
17 34
 
Halving the first column:
17 34
8
Line 20 ⟶ 17:
2
1
 
Doubling the second column:
17 34
8 68
Line 28 ⟶ 23:
2 272
1 544
 
Strike-out rows whose first cell is even:
17 34
8 --
Line 36 ⟶ 29:
2 ---
1 544
 
Sum the remaining numbers in the right-hand column:
 
17 34
8 --
Line 46 ⟶ 37:
====
578
 
So 17 multiplied by 34, by the Ethiopian method is 578.
 
The task is to '''define three functions'''/methods/procedures/subroutines:
 
# one to '''halve an integer''',
<br>'''The task is to define three functions/methods/procedures/subroutines: to half an integer; to double an integer; and one to state if an integer is even. Use these functions to create a function that does Ethiopian multiplication.'''<br>
# one to '''double an integer''', and
 
# one to '''state if an integer is even'''.
Use these functions to '''create a function that does Ethiopian multiplication'''.
 
'''References'''
:*[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]
 
=={{header|C}}==