Project Euler Problem 20
(defun sum-digits (x &optional (sum 0))
(multiple-value-bind (m n)
(truncate x 10)
(if (zerop m)
(+ n sum)
(sum-digits m (+ n sum)))))
(defun problem20 ()
(sum-digits
(reduce #'* (loop for i from 1 to 100 collect i))))
No comments:
Post a Comment