Skip to content

Instantly share code, notes, and snippets.

@ishikawa
Created August 12, 2008 02:58
Show Gist options
  • Select an option

  • Save ishikawa/4996 to your computer and use it in GitHub Desktop.

Select an option

Save ishikawa/4996 to your computer and use it in GitHub Desktop.
(define (fast-pow a n)
(cond ((= n 0) 1)
(else
(let ((x (fast-pow a (quotient n 2))))
(cond ((odd? n) (* a x x))
(else (* x x)))))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment