Drop hier links of afbeeldingen om ze aan de editor toe te voegen.

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.

Egyptian multiplication

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


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 numbers4 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) list5 marks

Calculate the numbers in the second (orange) list4 marks

Continuing code in the mul subprogram:

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

Continuing code in the mul subprogram:

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

Continuing code in the mul subprogram:

The output should now look like this:

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

Good programming practices3 marks

Maximum mark23

If you score less than 17 you need more practice at levels 1-6 before you continue to the next level.