Question: The Egyptian Division method is a tabular calculation that lends itself to a straightforward computer implemenation. The table starts out with a 1 in column

The Egyptian Division method is a tabular calculation that lends itself to a straightforward computer implemenation. The table starts out with a 1 in column a, the divisor in column b and the dividend in column c. Columns a and b are successively doubled until the value in column b is greater than the value in column c. At this point, we add a fourth column initialized to zero and aply the following algorithm. If the number in column b is less than or equal to that of column c, we add column a to column d and subtract column b from column c. Otherwise, we leave the values in c and d unchanged. In either case, we halve (integer division) the values in both columns a and b. We stop when column a becomes less that 1. At this point, the answer resides in column d.

DEFINE A FUNCTION NAMED EGYPT/ IN CLOJURE THAT TAKES TWO ARGUMENTS, THE DIVISOR AND THE DIVIDEND AND RETURNS THE QUOTIENT. EXAMPLE CALL: (egypt/ 1960 56)

Your mehtod should implement an iterative process. You may use neither multiplication nor division in your solution. Hint:::::: define two functions named double and halve which do their calculations using just addition and/ or subtraction. The halve function must run in a sub-linear time. Both double and halve should be visible, not nested.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!