diff --git a/src/Python/Problem053.py b/src/Python/Problem053.py index 15a7a7a..da018d3 100644 --- a/src/Python/Problem053.py +++ b/src/Python/Problem053.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python3 +#!/usr/bin/env python """ Created on 26 Sep 2021 @@ -9,7 +9,8 @@ Solution for problem 53 of Project Euler https://projecteuler.net/problem=53 """ -import math +from math import comb + from utils import timeit @@ -22,23 +23,23 @@ def compute(): 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. + 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. + 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? + 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: + if comb(x, y) > 1_000_000: ans += 1 return ans if __name__ == "__main__": - - print(f"Result for Problem 53: {compute()}") + print(f"Result for Problem 53 is {compute()}")