28 lines
604 B
Text
28 lines
604 B
Text
arraybase 1
|
|
dim table(32, 2)
|
|
dividend = 580
|
|
divisor = 34
|
|
|
|
i = 1
|
|
table[i, 1] = 1
|
|
table[i, 2] = divisor
|
|
|
|
while table[i, 2] < dividend
|
|
i = i + 1
|
|
table[i, 1] = table[i -1, 1] * 2
|
|
table[i, 2] = table[i -1, 2] * 2
|
|
end while
|
|
i = i - 1
|
|
answer = table[i, 1]
|
|
accumulator = table[i, 2]
|
|
|
|
while i > 1
|
|
i = i - 1
|
|
if table[i, 2]+ accumulator <= dividend then
|
|
answer = answer + table[i, 1]
|
|
accumulator = accumulator + table[i, 2]
|
|
end if
|
|
end while
|
|
|
|
print string(dividend); " divided by "; string(divisor); " using Egytian division";
|
|
print " returns "; string(answer); " mod(ulus) "; string(dividend-accumulator)
|