; approximate squaring
(define (asq x)
(define (sq x) (* x (ceiling x)))
(let loop ((x (sq x)) (xs (list x)))
(if (integer? x)
(reverse (cons x xs))
(loop (sq x) (cons x xs)))))
(display (asq 8/7)) (newline)
(display (asq 10/6)) (newline)
(define (asq-table d)
(do ((n (+ d 1) (+ n 1))) ((= n (+ d d)))
(let ((xs (asq (/ n d))))
(display n) (display " ")
(display (- (length xs) 1)) (display " ")
(display (car (reverse xs))) (newline))))
(asq-table 6)
(asq-table 8)
OyBhcHByb3hpbWF0ZSBzcXVhcmluZwoKKGRlZmluZSAoYXNxIHgpCiAgKGRlZmluZSAoc3EgeCkgKCogeCAoY2VpbGluZyB4KSkpCiAgKGxldCBsb29wICgoeCAoc3EgeCkpICh4cyAobGlzdCB4KSkpCiAgICAoaWYgKGludGVnZXI/IHgpCiAgICAgICAgKHJldmVyc2UgKGNvbnMgeCB4cykpCiAgICAgICAgKGxvb3AgKHNxIHgpIChjb25zIHggeHMpKSkpKQoKKGRpc3BsYXkgKGFzcSA4LzcpKSAobmV3bGluZSkKKGRpc3BsYXkgKGFzcSAxMC82KSkgKG5ld2xpbmUpCgooZGVmaW5lIChhc3EtdGFibGUgZCkKICAoZG8gKChuICgrIGQgMSkgKCsgbiAxKSkpICgoPSBuICgrIGQgZCkpKQogICAgKGxldCAoKHhzIChhc3EgKC8gbiBkKSkpKQogICAgICAoZGlzcGxheSBuKSAoZGlzcGxheSAiICIpCiAgICAgIChkaXNwbGF5ICgtIChsZW5ndGggeHMpIDEpKSAoZGlzcGxheSAiICIpCiAgICAgIChkaXNwbGF5IChjYXIgKHJldmVyc2UgeHMpKSkgKG5ld2xpbmUpKSkpCgooYXNxLXRhYmxlIDYpCihhc3EtdGFibGUgOCk=