How ancient Egyptians multiplied two numbers.
One method used by the ancient Egyptians to multiply two numbers was discovered in the Rhind Mathematical Papyri written in approximately 1550 B.C. and discovered in Thebes in 1650. It inspired how binary computers could perform such arithmetic as many had no multiply operator until the late 1970s.
The algorithm requires taking the first number and repeatedly integer dividing it by two until the number equals one, writing each new number in a list. The second number is then multiplied by two the same number of times with the results recorded in a second list. A number is removed from the list if the number in the first column is even. The sum of the remaining numbers in the second column is the result of the multiplication.
13 * 28 = 364
These objectives get progressively harder. Attempt as much of the program as you can in the order presented below. Remember to use a comment to describe a subpprogram, selection or iteration.
input_numbers that takes no parameters.
input_numbers.4 marks
Enter the first number: 13
Enter the second number: 28
mul that takes one parameter that is the list containing the two numbers to multiply.
first_number and second_number to be the two numbers in the list.first_number into a list called column1.first_number is assigned to be itself integer divided by 2.first_number to the column1 list.first number is greater than 1.5 marks
Continuing code in the mul subprogram:
second_number into a list called column2.second_number is assigned to be itself multiplied by 2.second_number to the column2 list.4 marks
Continuing code in the mul subprogram:
column1 is an even number.column2 if the number was an even number.3 marks
Continuing code in the mul subprogram:
column2.mul with the list containing just the two numbers to multiply.4 marks
Enter the first number: 13
Enter the second number: 28
364
mul subprogram has a comment to describe what it does.3 marks
Maximum mark: 23
If you score less than 17 you need more practice at levels 1-6 before you continue to the next level.