diff --git a/src/Python/Problem053.py b/src/Python/Problem053.py new file mode 100644 index 0000000..4f8896a --- /dev/null +++ b/src/Python/Problem053.py @@ -0,0 +1,44 @@ +#!/usr/bin/env python3 +""" +Created on 26 Sep 2021 + +@author: David Doblas Jiménez +@email: daviddoji@pm.me + +Solution for problem 53 of Project Euler +https://projecteuler.net/problem=53 +""" + +import math +from utils import timeit + + +@timeit("Problem 53") +def compute(): + """ + 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, (5 over 3) = 10. + + In general, (n over r) = n!/r!*(n-r)!, where r<=n, n!=n*(n-1)*...*2*1, and 0!=1. + + It is not until + , that a value exceeds one-million: (23 over 10) = 1144066. + + How many, not necessarily distinct, values of (n over r) for 1<=n<=100, are greater than one-million? + """ + + ans = 0 + for x in range(101): + for y in range(101): + if math.comb(x, y) > 1_000_000: + ans += 1 + + return ans + + +if __name__ == "__main__": + + print(f"Result for Problem 53: {compute()}") \ No newline at end of file