Skip to content
Browse files

fixed 1.16

  • Loading branch information...
1 parent a3adae5 commit b6f33ef82ab1653c8c2995ffefea50c7788fdc65 Robert Campbell committed Dec 4, 2011
Showing with 5 additions and 5 deletions.
  1. +5 −5 src/sicp/chapter1/section2.clj
View
10 src/sicp/chapter1/section2.clj
@@ -105,9 +105,9 @@
(letfn [(square [x] (* x x))]
(defn fast-expt' [b n]
- (loop [n' n a b]
- (cond (= n' 1) a
- (even? n') (recur (/ n' 2)
- (square a))
- :else (recur (dec n')
+ (loop [n n a 1]
+ (cond (zero? n) a
+ (even? n) (recur (/ n 2)
+ (* b (square a)))
+ :else (recur (dec n)
(* b a))))))

0 comments on commit b6f33ef

Please sign in to comment.
Something went wrong with that request. Please try again.