Last active
June 26, 2018 03:59
-
-
Save federkasten/f6d17152abcf133acaae to your computer and use it in GitHub Desktop.
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
(declare expect-memo) | |
(defn expect* | |
[n t] | |
(if (zero? t) | |
n | |
(let [nn (inc n) | |
ps (/ 1 nn) | |
pf (- 1 ps) | |
es (* ps (expect-memo nn (dec t))) | |
ef (* pf (expect-memo 0 (dec t))) | |
e (+ es ef)] | |
(max n e)))) | |
(def expect-memo (memoize expect*)) | |
(def expect #(expect-memo 0 %)) |
(数年越しのreplyですが)更新しました。ありがとうございます!
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
ふと、
の部分は、
で良いのではないか、と思いました。