Gotta love these easy ones
This commit is contained in:
40
53/main.py
Normal file
40
53/main.py
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
'''
|
||||||
|
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,
|
||||||
|
.
|
||||||
|
|
||||||
|
In general,
|
||||||
|
|
||||||
|
, where , , and .
|
||||||
|
|
||||||
|
It is not until , that a value exceeds one-million:
|
||||||
|
.
|
||||||
|
|
||||||
|
How many, not necessarily distinct, values of
|
||||||
|
for , are greater than one-million?
|
||||||
|
'''
|
||||||
|
# Okay I have to admit that it looks really bad without the math equations
|
||||||
|
|
||||||
|
import time
|
||||||
|
import math
|
||||||
|
|
||||||
|
|
||||||
|
def main():
|
||||||
|
print("Hello, this is Patrick")
|
||||||
|
t0 = time.time()
|
||||||
|
|
||||||
|
tooBig = 1000000
|
||||||
|
counter = 0
|
||||||
|
|
||||||
|
for n in range(1, 101):
|
||||||
|
for r in range(1, n+1):
|
||||||
|
if math.comb(n, r) > tooBig:
|
||||||
|
counter += 1
|
||||||
|
|
||||||
|
print(counter, time.time() - t0)
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
main()
|
||||||
Reference in New Issue
Block a user