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: | Line 3: | ||
'''Method:'''<br> |
'''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 |
|||
'''For example:''' 17 x 34 |
'''For example:''' 17 x 34 |
||
17 34 |
17 34 |
||
Halving the first column: |
Halving the first column: |
||
17 34 |
17 34 |
||
8 |
8 |
||
Line 20: | Line 17: | ||
2 |
2 |
||
1 |
1 |
||
Doubling the second column: |
Doubling the second column: |
||
17 34 |
17 34 |
||
8 68 |
8 68 |
||
Line 28: | Line 23: | ||
2 272 |
2 272 |
||
1 544 |
1 544 |
||
Strike-out rows whose first cell is even: |
Strike-out rows whose first cell is even: |
||
17 34 |
17 34 |
||
8 -- |
8 -- |
||
Line 36: | Line 29: | ||
2 --- |
2 --- |
||
1 544 |
1 544 |
||
Sum the remaining numbers in the right-hand column: |
Sum the remaining numbers in the right-hand column: |
||
17 34 |
17 34 |
||
8 -- |
8 -- |
||
Line 46: | Line 37: | ||
==== |
==== |
||
578 |
578 |
||
So 17 multiplied by 34, by the Ethiopian method is 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''' |
'''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}}== |
=={{header|C}}== |