Created
July 2, 2011 08:38
-
-
Save arosh/1059866 to your computer and use it in GitHub Desktop.
Project Euler Problem 1 by LISP
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
LISPのれんしゅーです。
再帰まで覚えました。
きっと心優しいLISPerが添削してくれるはず