Skip to content

Instantly share code, notes, and snippets.

@cdinu
Created August 12, 2016 09:07
Show Gist options
  • Save cdinu/26b61eb06d93faab2dfa5d28ce66eba6 to your computer and use it in GitHub Desktop.
Save cdinu/26b61eb06d93faab2dfa5d28ce66eba6 to your computer and use it in GitHub Desktop.
Statistics about the powers of two
(defn powow
[n]
(let [
exp (fn exp [x n] (reduce * (repeat n x)))
pow (str (exp 2N n))
len (count pow)
sum (reduce
(fn
[sum x]
(+ sum (- (int x) (int \0))))
0
pow)]
(vector pow sum len (/ sum len 1.0))))
(powow 100)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment