Created
February 24, 2015 02:05
-
-
Save kouddy/4b9e824f2a900f6bb4ca to your computer and use it in GitHub Desktop.
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
| (define (double n) (* n 2)) | |
| (define (halve n) (/ n 2)) | |
| (define (even? n) (= (remainder n 2) 0)) | |
| (define (fast-mult a b) | |
| (cond ((= b 0) 0) | |
| ((even? b) (double (fast-mult a (halve b)))) | |
| (else (+ a (fast-mult a (- b 1)))))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment