Created
April 10, 2013 12:02
-
-
Save bitdewy/5354015 to your computer and use it in GitHub Desktop.
Project Euler #6 in Common 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
;;;; | |
;;;; 6.lisp | |
;;;; ProjectEuler | |
;;;; | |
;;;; Created by bitdewy on 4/10/13. | |
;;;; Copyright (c) 2013 bitdewy. All rights reserved. | |
;;;; | |
;; Project Euler #6 | |
(defun square (x) | |
(* x x)) | |
(defun sum_of_natural_numbers (max) | |
(do ((result 0) (i 0 (1+ i))) | |
((> i max) result) | |
(setf result (+ result i)))) | |
(defun sum_of_natural_numbers_square (max) | |
(do ((result 0) (i 0 (1+ i))) | |
((> i max) result) | |
(setf result (+ result (square i))))) | |
(- (square (sum_of_natural_numbers 100)) (sum_of_natural_numbers_square 100)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment