28 lines
643 B
Text
28 lines
643 B
Text
DIM table(32, 2)
|
|
LET dividend = 580
|
|
LET divisor = 34
|
|
|
|
LET i = 1
|
|
LET table(i, 1) = 1
|
|
LET table(i, 2) = divisor
|
|
|
|
DO WHILE table(i, 2) < dividend
|
|
LET i = i+1
|
|
LET table(i, 1) = table(i-1, 1)*2
|
|
LET table(i, 2) = table(i-1, 2)*2
|
|
LOOP
|
|
LET i = i-1
|
|
LET answer = table(i, 1)
|
|
LET accumulator = table(i, 2)
|
|
|
|
DO WHILE i > 1
|
|
LET i = i-1
|
|
IF table(i, 2)+accumulator <= dividend THEN
|
|
LET answer = answer+table(i, 1)
|
|
LET accumulator = accumulator+table(i, 2)
|
|
END IF
|
|
LOOP
|
|
|
|
PRINT STR$(dividend); " divided by "; STR$(divisor); " using Egytian division";
|
|
PRINT " returns "; STR$(answer); " mod(ulus) "; STR$(dividend-accumulator)
|
|
END
|