Created
March 24, 2016 05:23
-
-
Save Scinawa/c54d11ec4b8d28c3bd10 to your computer and use it in GitHub Desktop.
Stirling number of the first kind
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
@memo # can be memoized, otherwise comment this line | |
def stirling1(n,k): | |
"""Returns the stirling number of the first kind using recursion..""" | |
if n == 0 and k == 0: | |
return 1 | |
if k == 0 and n >= 1: | |
return 0 | |
if k > n: | |
return 0 | |
return stirling1(n-1, k-1) - (n - 1) * stirling1(n-1, k) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment