Common Lisp version of the MaxParts function
By: a guest | Mar 19th, 2010 | Syntax:
Lisp | Size: 0.40 KB | Hits: 84 | Expires: Never
;;; The mp function will calculate the maximal number of pieces resulting from C planar cuts through a D-dimensional object.
;;; An example of this in 3-space are the cake numbers, described here: http://www.research.att.com/njas/sequences/A000125
(defun mp (D C)
(if (>= D C)
(expt 2 C)
(if (= D 0)
1
(if (= C 0)
1
(+ (mp (- D 1) (- C 1)) (mp D (- C 1)))))))