Skip to content

Instantly share code, notes, and snippets.

@bitdewy
Created April 10, 2013 12:02
Show Gist options
  • Save bitdewy/5354015 to your computer and use it in GitHub Desktop.
Save bitdewy/5354015 to your computer and use it in GitHub Desktop.
Project Euler #6 in Common LIsp
;;;;
;;;; 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