Problem 22 (not a purely LISP solution).