combinatoric selections problem 53 there are exactly ten ways of selecting three from five 12345 123 124 125 134 135 145 234 235 245 and 345 in combinatorics we use the notation 5c3 10 in general ncr n r nr where r n n nn1 321 and 0 1 it is not until n 23 that a value exceeds onemillion 23c10 1144066 how many not necessarily distinct values of ncr for 1 n 100 are greater than onemillion returns the number of values of ncr for 1 n 100 are greater than onemillion solution 4075 returns the number of values of ncr for 1 n 100 are greater than one million solution 4075
from math import factorial


def combinations(n, r):
    return factorial(n) / (factorial(r) * factorial(n - r))


def solution():
    
    total = 0

    for i in range(1, 101):
        for j in range(1, i + 1):
            if combinations(i, j) > 1e6:
                total += 1
    return total


if __name__ == "__main__":
    print(solution())