-
Notifications
You must be signed in to change notification settings - Fork 64
/
Copy pathapp.py
33 lines (32 loc) · 857 Bytes
/
app.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import math
import operator as op
from functools import reduce
from math import factorial
def nPr(n, r):
return int(factorial(n)/factorial(n-r))
def ncr(n, r):
r = min(r, n-r)
numer = reduce(op.mul, range(n, n-r, -1), 1)
denom = reduce(op.mul, range(1, r+1), 1)
return numer // denom
def root(a,b,c):
try:
delta=b**2-4*a*c
x1=(-b+math.sqrt(delta))/(2*a)
x2=(-b-math.sqrt(delta))/(2*a)
if x1>0:
return x1
else:
return x2
except:
raise ValueError
p=nPr(2048,12)
print(nPr(3,2))
p2=pow(2048,12)
solution=root(1,-1,-(math.log(2))*2*p)
solution2=root(1,-1,-(math.log(2))*2*p2)
print("All the potential options:"+"{:e}".format(p))
print("{:e}".format(solution))
print("\n\n")
print("All the potential options:"+"{:e}".format(p2))
print("{:e}".format(solution2))