Created
February 21, 2014 18:47
-
-
Save emadshaaban92/9140651 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
#! /usr/bin/env python3 | |
from math import factorial | |
#from functools import lru_cache | |
MAXN = 100 | |
MAXNCR = 1000000 | |
import time | |
before = time.time() | |
#factorial = lru_cache(maxsize=None)(factorial) | |
def nCr(n, r): | |
return factorial(n) / factorial(r) / factorial(n-r) | |
result = 0 | |
for n in range(1,MAXN+1): | |
for r in range(1,n) : | |
if nCr(n, r) > MAXNCR : | |
result += 1 | |
print(result) | |
print(time.time()-before) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment