Created
August 22, 2008 21:49
-
-
Save jeremyBanks/6860 to your computer and use it in GitHub Desktop.
[2010-01] experimenting with sbcl, i guess
This file contains hidden or 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
#!/usr/bin/env sbclx | |
(let | |
((sum 0)) ; the sum of the even valued terms of fib | |
; this is the only variable we need outside of the scope of the loop | |
(do | |
( | |
(ubound 4000000) ; that do not excede this value | |
(previous 1) ; the value of the previous term | |
(current 1) ; the value of the current term | |
) | |
((> current ubound)) ; don't excede the limti! | |
(if | |
(= | |
0 | |
(mod current 2) | |
) | |
(setq sum (+ sum current)) | |
) | |
(let | |
( | |
(tempCurrent current) | |
) | |
(setq current (+ previous current)) | |
(setq previous tempCurrent) | |
) | |
) | |
(print sum) | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment