Skip to content

Instantly share code, notes, and snippets.

@meadhikari
Created October 11, 2012 16:03
Show Gist options
  • Save meadhikari/3873415 to your computer and use it in GitHub Desktop.
Save meadhikari/3873415 to your computer and use it in GitHub Desktop.
First common lisp function
;Add all the natural numbers below one thousand that are multiples of 3 or 5.
(defun sum-to-last (x)
(cond ((eql x 0)
0)
(t
(let ((mod3 (eql (mod x 3) 0))
(mod5 (eql (mod x 5) 0))
)
(cond ((or mod3 mod5)
(+ x (sum-to-last (1- x)))
)
(t (sum-to-last (1- x)))
)))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment