Skip to content

Instantly share code, notes, and snippets.

@bitdewy
Created April 10, 2013 06:21
Show Gist options
  • Save bitdewy/5352232 to your computer and use it in GitHub Desktop.
Save bitdewy/5352232 to your computer and use it in GitHub Desktop.
Project Euler #5 in Common Lisp
;;;;
;;;; 5.lisp
;;;; ProjectEuler
;;;;
;;;; Created by bitdewy on 4/10/13.
;;;; Copyright (c) 2013 bitdewy. All rights reserved.
;;;;
;; Project Euler #5
(defun smallest_multiple1 (max)
(do ((a 1 (1+ a)) (result 1 (lcm result a)))
((> a max) result)
t))
(smallest_multiple1 20)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defun smallest_multiple2 (max)
(reduce #'lcm
(do ((sequence nil) (i 1 (1+ i)))
((> i max) sequence)
(push i sequence))))
(smallest_multiple2 20)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment