64 lines
568 B
Text
64 lines
568 B
Text
alert "integer square root of first 65 numbers:"
|
|
|
|
for n = 1 to 65
|
|
|
|
let x = n
|
|
gosub isqrt
|
|
print r
|
|
|
|
next n
|
|
|
|
alert "integer square root of odd powers of 7"
|
|
cls
|
|
cursor 1, 1
|
|
|
|
for n = 1 to 21 step 2
|
|
|
|
let x = 7 ^ n
|
|
gosub isqrt
|
|
print "isqrt of 7 ^ ", n, " = ", r
|
|
|
|
next n
|
|
|
|
end
|
|
|
|
sub isqrt
|
|
|
|
let q = 1
|
|
|
|
do
|
|
|
|
if q <= x then
|
|
|
|
let q = q * 4
|
|
|
|
endif
|
|
|
|
wait
|
|
|
|
loop q <= x
|
|
|
|
let r = 0
|
|
|
|
do
|
|
|
|
if q > 1 then
|
|
|
|
let q = q / 4
|
|
let t = x - r - q
|
|
let r = r / 2
|
|
|
|
if t >= 0 then
|
|
|
|
let x = t
|
|
let r = r + q
|
|
|
|
endif
|
|
|
|
endif
|
|
|
|
loop q > 1
|
|
|
|
let r = int(r)
|
|
|
|
return
|