Skip to content

Instantly share code, notes, and snippets.

@tasuten
Created January 1, 2015 15:10
Show Gist options
  • Save tasuten/e0f099f8ae7eeda78462 to your computer and use it in GitHub Desktop.
Save tasuten/e0f099f8ae7eeda78462 to your computer and use it in GitHub Desktop.
書き初め@2015
#!/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