Blob
1 (define (* a b)2 (if (= b 0)3 04 (+ a (* a (- b 1)))))6 ;; a * b = {7 ;; 0 if b = 0,8 ;; 2 * a * (b/2) if b is even,9 ;; a + a * (b-1) if b is odd10 ;; }12 (define (fast-mult a b)13 (cond ((= b 0) 0)14 ((even? b) (double (* a (halve b))))15 (else (+ a (* a (- b 1))))))17 (define (test-case actual expected)18 (load-option 'format)19 (newline)20 (format #t "Actual: ~A Expected: ~A" actual expected))21 (test-case (fast-expt-iter 2 1 0) 2)