I hereby claim:
- I am djrodgerspryor on github.
- I am drodgers (https://keybase.io/drodgers) on keybase.
- I have a public key ASBsRbmrdKv1yrMSp0y1K3HmQJapQ4J1Rfwn5lkYCO3K5wo
To claim this, I am signing this object:
I hereby claim:
To claim this, I am signing this object:
def pascalRow(n): | |
" Returns the nth row of Pascal's triangle" | |
return [1] if n<=0 else reduce(lambda row, n: row[:-1] + [(row[-1] + n), n], pascalRow(n-1), [0]) | |
if __name__ == '__main__': # Module Test/Demo | |
print pascalRow(12) | |
print '\n'.join([str(n) + ' : ' + str(pascalRow(n)) for n in xrange(10)]) |
from itertools import takewhile, chain, count, islice | |
from collections import deque | |
knownPrimes = [2] # Numbers are tested by counting upwards from here. This also acts as a cache. | |
def storeAndReturn(p): | |
knownPrimes.append(p) | |
return p | |
def isNotDivisibleByKnownPrimes(n): |