Created
January 1, 2015 15:10
-
-
Save tasuten/e0f099f8ae7eeda78462 to your computer and use it in GitHub Desktop.
書き初め@2015
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
#!/usr/local/bin/gosh | |
(define (collatz-next n) | |
(cond | |
((even? n) (/ n 2)) | |
((odd? n) (+ (* n 3) 1))) | |
) | |
(define (collatz n) | |
(if (<= n 1) '(1) | |
(cons n (collatz (collatz-next n))) | |
) | |
) | |
(define (main args) | |
(print (collatz 2015)) | |
0 ) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment