Hi,
I have tested the latest commit by Robert, with the cf patch contributed
by Alexander Klimov,
and the tests proposed by Jean-Claude still fail for some numbers.
Testing for sqrt(1) thru sqrt(1000), cf fails for 200 when cflength=1,
but it works for 2, 3, 4 or 5.
And cf(sqrt(n)) seems to be wrong (cflength=1) for the following numbers:
72, 108, 288, 392, 432, 500, 648, 800, 864, 968, 972
I got the same results using SBCL, CCL, GCL, CLisp and ECL in Ubuntu.
The test batch file I used was the following:
cf_sqrt(d) := block(
[a: 0, b: 1, r: isqrt(d), v: [ ], n],
if r * r = d then return([r]),
do (
n: quotient(a + r, b),
v: endcons(n, v),
a: b * n - a,
b: quotient(d - a * a, b),
if b = 1 then return(endcons(a + r, v))
)
)$
for cflength thru 5 do
print(cflength,sublist(makelist(i,i,1000), lambda([n],
integerp(cf(sqrt(n))))));
wrong: setify(sublist(makelist(i,i,1000), lambda([n], cf_sqrt(n) #
cf(sqrt(n)))))$
display(wrong);
Regards,
Jaime