Last active
October 8, 2015 10:59
-
-
Save sheepcloud/898e7d9d69da26c3411b to your computer and use it in GitHub Desktop.
Pythonで総和を実装 ref: http://qiita.com/SheepCloud/items/b8bd929c4f35dfd7b1bd
This file contains hidden or 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
\sum_{i=m}^{n} f(x) = f(m) + f(m+1) + \cdots + f(n) \\ |
This file contains hidden or 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
def sigma(m, n, func, s = 0) : | |
if m > n: return s | |
return sigma(m + 1, n, func, s + func(m)) |
This file contains hidden or 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
print(sigma(1, 10, lambda x : x)) | |
55 | |
print(sigma(1, 3, lambda x : 3 * 5 ** (x - 1))) | |
93 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment