Skip to content

Instantly share code, notes, and snippets.

@sheepcloud
Last active October 9, 2015 01:40
Show Gist options
  • Save sheepcloud/44f3b2d67b025f231a20 to your computer and use it in GitHub Desktop.
Save sheepcloud/44f3b2d67b025f231a20 to your computer and use it in GitHub Desktop.
# coding: utf-8
# Here your code !
import numpy as np
# (n Σ i = m) = func(m) + func(m+1) + ... + func(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))
func = lambda x: x
print(func(range(1, 10+1)))
import numpy as np
func = lambda x: x
print(func(np.arange(10)+1).sum())
print(type(np.arange(10)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment