Last active
January 11, 2018 01:56
-
-
Save jeancochrane/3bcd2bb2a6518db495f3b11d01df5767 to your computer and use it in GitHub Desktop.
A Scheme implementation of CracklePop!
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
(define (crackle-pop) | |
(define (iter n) | |
(let ((divisible-by-3 (= 0 (remainder n 3))) | |
(divisible-by-5 (= 0 (remainder n 5)))) | |
(cond ((> n 100) "Done printing CracklePop :~)") | |
(else | |
(cond ((or divisible-by-3 divisible-by-5) | |
(if divisible-by-3 (display "Crackle")) | |
(if divisible-by-5 (display "Pop"))) | |
(else (display n))) | |
(newline) | |
(iter (+ n 1)))))) | |
(iter 1)) | |
(crackle-pop) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment