Data commit

This commit is contained in:
Ingy döt Net 2023-07-01 11:58:00 -04:00
parent 7387c8f97b
commit cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions

View file

@ -0,0 +1,61 @@
# -*- ObjectIcon -*-
import io
import ipl.numbers # For the "commas" procedure.
import ipl.printf
procedure main ()
write ("isqrt(i) for 0 <= i <= 65:")
write ()
roots_of_0_to_65()
write ()
write ()
write ("isqrt(7**i) for 1 <= i <= 73, i odd:")
write ()
printf ("%2s %84s %43s\n", "i", "7**i", "sqrt(7**i)")
write (repl("-", 131))
roots_of_odd_powers_of_7()
end
procedure roots_of_0_to_65 ()
local i
every i := 0 to 64 do writes (isqrt(i), " ")
write (isqrt(65))
end
procedure roots_of_odd_powers_of_7 ()
local i, power_of_7, root
every i := 1 to 73 by 2 do {
power_of_7 := 7^i
root := isqrt(power_of_7)
printf ("%2d %84s %43s\n", i, commas(power_of_7), commas(root))
}
end
procedure isqrt (x)
local q, z, r, t
q := find_a_power_of_4_greater_than_x (x)
z := x
r := 0
while 1 < q do {
q := ishift(q, -2)
t := z - r - q
r := ishift(r, -1)
if 0 <= t then {
z := t
r +:= q
}
}
return r
end
procedure find_a_power_of_4_greater_than_x (x)
local q
q := 1
while q <= x do q := ishift(q, 2)
return q
end