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

Egyptian multiplication

Assessment

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.

Success Criteria

Input the two numbers

4 marks

The output should now look like this:

Enter the first number: 13
Enter the second number: 28

Calculate the numbers in the first (blue) list

5 marks

Calculate the numbers in the second (orange) list

Continuing code in the mul subprogram:

4 marks

Removing a row in the second (orange) list for all even numbers in the first (blue) list

Continuing code in the mul subprogram:

3 marks

Adding all the numbers in the second (orange) list and outputting the result

Continuing code in the mul subprogram:

4 marks

The output should now look like this:

Enter the first number: 13
Enter the second number: 28
364

Good programming practices

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.