Skip to content

Instantly share code, notes, and snippets.

@marsam
Last active December 18, 2015 23:48
Show Gist options
  • Select an option

  • Save marsam/5863659 to your computer and use it in GitHub Desktop.

Select an option

Save marsam/5863659 to your computer and use it in GitHub Desktop.
project euler solutions in elisp

Euler solutions in elisp

Just for fun

  • Problem 1
  • Problem 2
  • Problem 3
  • Problem 4
(require 'cl)

;; Problem 1

(apply '+ (remove-if-not '(lambda (x) (or (zerop (% x 3)) (zerop (% x 5)))) (loop for i from 1 to 999 collect i)))

;; Problem 2
(defun fibonacci (n)
  (labels ((calc-fib (n a b)
                     (if (= n 0)
                       a
                       (calc-fib (- n 1) b (+ a b)))))
    (calc-fib n 0 1)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment