Adopted new convention from template
This commit is contained in:
parent
e0dd2faa94
commit
3fde5ebc71
@ -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()}")
|
||||
|
Loading…
x
Reference in New Issue
Block a user