Created
December 13, 2019 22:28
-
-
Save tonetheman/8e4c273533292d812ad5d44d1e8db784 to your computer and use it in GitHub Desktop.
collatz in racket
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
#lang racket | |
(define (foo n) | |
(if (= (modulo n 2) 0) | |
(/ n 2) | |
(+ (* 3 n) 1) | |
)) | |
(define (goo a) | |
(println a) | |
(if (= (first a) 4) | |
a | |
(goo (cons (foo (first a)) a)) | |
) | |
) | |
(goo (list 100)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment