> <\body> <\session|s7|default> <\unfolded-io> \\ <|unfolded-io> (define (expt-1 b n) \ \ (if (= n 0) \ \ \ \ \ \ 1 \ \ \ \ \ \ (* b (expt-1 b (- n 1))))) <|unfolded-io> expt-1 <\unfolded-io> \\ <|unfolded-io> (expt-1 1 0) <|unfolded-io> 1 <\unfolded-io> \\ <|unfolded-io> (expt-1 2 3) <|unfolded-io> 8 <\unfolded-io> \\ <|unfolded-io> (define (expt-2 b n) \ \ (define (expt-iter b counter product) \ \ \ \ (if (= counter 0) \ \ \ \ \ \ \ \ product \ \ \ \ \ \ \ \ (expt-iter b \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ (- counter 1) \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ (* b product)))) \ \ \ \ (expt-iter b n 1)) <|unfolded-io> expt-2 <\unfolded-io> \\ <|unfolded-io> (expt-2 3 3) <|unfolded-io> 27 <\input> \\ <|input> \; <\session|s7|default> <\unfolded-io> \\ <|unfolded-io> (define (fast-expt b n) \ \ (define (even? n) \ \ \ \ (= (remainder n 2) 0)) \ \ (define (square x) (* x x)) \ \ \ \ (cond ((= n 0) 1) \ \ \ \ \ \ \ \ ((even? n) (square (fast-expt b (/ n 2)))) \ \ \ \ \ \ \ \ (else (* b (fast-expt b (- n 1)))))) <|unfolded-io> fast-expt <\unfolded-io> \\ <|unfolded-io> (fast-expt 3 3) <|unfolded-io> 27 <\input> \\ <|input> \; <\session|s7|default> <\unfolded-io> \\ <|unfolded-io> (define (gcd a b) \ \ (if (= b 0) \ \ \ \ \ \ a \ \ \ \ \ \ (gcd b (remainder a b)))) <|unfolded-io> gcd <\unfolded-io> \\ <|unfolded-io> (gcd 10 20) <|unfolded-io> 10 <\input> \\ <|input> \; <\initial> <\collection> <\references> <\collection> > > > <\auxiliary> <\collection> <\associate|toc> |math-font-series||Orders of Growth> |.>>>>|> |math-font-series||Exponentiation> |.>>>>|> |math-font-series||Greatest Common Divisors> |.>>>>|>