lisp

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)

Learning Lisp Fast - Part 3

(Source and copyright: Sean Luke - George Mason University, cs.gmu.edu/~sean/lisp/LispTutorial3.html)

Learning Lisp Fast - Part 2

(Source and copyright: Sean Luke - George Mason University, cs.gmu.edu/~sean/lisp/LispTutorial2.html)

Learning Lisp Fast - Part 1

(Source and copyright: Sean Luke - George Mason University, cs.gmu.edu/~sean/lisp/LispTutorial.html)

The Road To Lisp

Syndicate content