Last active
October 9, 2015 01:40
-
-
Save sheepcloud/44f3b2d67b025f231a20 to your computer and use it in GitHub Desktop.
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
# 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