Created
August 12, 2016 09:07
-
-
Save cdinu/26b61eb06d93faab2dfa5d28ce66eba6 to your computer and use it in GitHub Desktop.
Statistics about the powers of two
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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