Created
November 8, 2016 18:09
-
-
Save fschr/5968bf74e4d12929c664fd7f59ddde12 to your computer and use it in GitHub Desktop.
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
#!/bin/python2.7 | |
def D(n): | |
if n == 0: | |
return 1 | |
if n == 1: | |
return 0 | |
a, b = 1, 0 | |
for i in range(1, n, 2): | |
a = i * (a + b) | |
b = (i + 1) * (b + a) | |
return b if n % 2 == 1 else a | |
def slowD(n): | |
if n == 0: | |
return 1 | |
if n == 1: | |
return 0 | |
return (n-1)*(slowD(n-1) + slowD(n-2)) | |
def main(): | |
print D(10000) | |
if __name__ == "__main__": | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment