Skip to content

Instantly share code, notes, and snippets.

@emadshaaban92
Created February 21, 2014 18:47
Show Gist options
  • Save emadshaaban92/9140651 to your computer and use it in GitHub Desktop.
Save emadshaaban92/9140651 to your computer and use it in GitHub Desktop.
#! /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