-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathutils.py
More file actions
31 lines (24 loc) · 803 Bytes
/
utils.py
File metadata and controls
31 lines (24 loc) · 803 Bytes
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
import sympy
import asyncio
def get_germain_prime(bits):
# Set the range of values to search for a Germain prime
start = 2**(bits-1)
end = 2**bits
# Iterate through the range of values and check if each is a Germain prime
for n in range(start, end):
p = 2*n + 1
if sympy.isprime(p) and sympy.isprime(2*p + 1):
# print("The Germain prime is:", p)
break
return p
def lagrange_basis_polynomial(i, x, selected_indices, n_fact = 1):
out = n_fact # This prevents floating point errors
for j in selected_indices:
if j != i:
out *= (x - j)
out //=(i - j)
return out
async def update_gui_periodically(gui, interval=0.01):
while True:
gui.update()
await asyncio.sleep(interval)