Skip to content

Instantly share code, notes, and snippets.

@sheepcloud
Last active October 8, 2015 10:59
Show Gist options
  • Save sheepcloud/898e7d9d69da26c3411b to your computer and use it in GitHub Desktop.
Save sheepcloud/898e7d9d69da26c3411b to your computer and use it in GitHub Desktop.
\sum_{i=m}^{n} f(x) = f(m) + f(m+1) + \cdots + f(n) \\
def sigma(m, n, func, s = 0) :
if m > n: return s
return sigma(m + 1, n, func, s + func(m))
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