Skip to content

Instantly share code, notes, and snippets.

@arosh
Created July 2, 2011 08:38
Show Gist options
  • Save arosh/1059866 to your computer and use it in GitHub Desktop.
Save arosh/1059866 to your computer and use it in GitHub Desktop.
Project Euler Problem 1 by LISP
(define inputMax 999)
(define (isMultiOf5 n) (if (= (modulo n 5) 0) #t #f))
(define (isMultiOf3 n) (if (= (modulo n 3) 0) #t #f))
(define (isMulti n) (if (isMultiOf3 n) #t (isMultiOf5 n)))
(define (solve n) (if (= n 0) 0 (+ (if (isMulti n) n 0) (solve (- n 1)))))
(display (solve inputMax))
@arosh
Copy link
Author

arosh commented Jul 2, 2011

LISPのれんしゅーです。
再帰まで覚えました。

きっと心優しいLISPerが添削してくれるはず

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment