mathematics

Unable to create scaled Original image

Farey-Cauchy sequence in Lisp

A short and simple algorithm in Common Lisp for the Farey-Cauchy sequence. Among other things (reformulating the Riemann hypothesis, etc), it helps with the "Ford's touching circles" problem.

(defun farey-cauchy (n)
(let ((a 0) (b 1) (c 1) (d n) k f e)
(format t "~a/~a " a b)
(loop while (< c n) do
(setq k (floor (/ (+ n b) d))
e (- (* k c) a)
f (- (* k d) b)
a c
b d
c e
d f)
(format t "~a/~a " a b))))

CL-USER> (farey-cauchy 7)

Syndicate content