Skip to content

Instantly share code, notes, and snippets.

@Licenser
Created June 19, 2010 11:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Licenser/444827 to your computer and use it in GitHub Desktop.
Save Licenser/444827 to your computer and use it in GitHub Desktop.
(defn- expt-int [base pow]
(loop [n pow, y 1, z base]
(let [t (bit-and n 1), n (bit-shift-right n 1)]
(cond
(zero? t) (recur n y (* z z))
(zero? n) (* z y)
:else (recur n (* z y) (* z z))))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment