31 lines
606 B
Text
31 lines
606 B
Text
print "Integer square root of first 65 numbers:"
|
|
for n = 1 to 65
|
|
print ljust(isqrt(n),3);
|
|
next n
|
|
print : print
|
|
print "Integer square root of odd powers of 7"
|
|
print " n 7^n isqrt"
|
|
print "-"*36
|
|
for n = 1 to 21 step 2
|
|
pow7 = int(7 ^ n)
|
|
print rjust(n,3);rjust(pow7,20);rjust(isqrt(pow7),12)
|
|
next n
|
|
end
|
|
|
|
function isqrt(x)
|
|
q = 1
|
|
while q <= x
|
|
q *= 4
|
|
end while
|
|
r = 0
|
|
while q > 1
|
|
q /= 4
|
|
t = x - r - q
|
|
r /= 2
|
|
if t >= 0 then
|
|
x = t
|
|
r += q
|
|
end if
|
|
end while
|
|
return int(r)
|
|
end function
|