Created
June 21, 2020 17:29
-
-
Save ourmaninamsterdam/6af06bf3e0c50da96795b41b3b26979f to your computer and use it in GitHub Desktop.
Simple factorial fn 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
(check-expect (fact 0) 1) | |
(check-expect (fact 3) 6) | |
(define (fact n) | |
(cond [(zero? n) 1] | |
[else | |
(* n | |
(fact (sub1 n)))])) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment