forked from Leoleojames1/Divisor-Wave-Prime-Complex-Analysis
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Prime_Finder_Product_Script.py
60 lines (54 loc) · 1.66 KB
/
Prime_Finder_Product_Script.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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
"""
Prime_Finder_Product_Script:
This script was designed to calculate the prime numbers up to a given x value using the infinite
product of the infinite product representation of sin(pi*x/n) through the use of a piecewise function.
4/9/2023
@LeoBorcherding
"""
import math
import numpy as np
import scipy
from scipy import special
def b(x):
"""
Computes the product of the product representation for sin(z).
∏_(n=2)^x (pi*x) ∏_(n=2)^x (1-(x^2)/(i^2)(n^2))
Args:
x (Real): A real, whole number to evaluate.
Returns:
(int): The product of the product representation for sin(z).
"""
result = abs(np.prod([x / n * (x * math.pi) * np.prod(
[1 - x ** math.pi / (n ** math.pi * k ** math.pi) for k in range(2, int(x) + 1)]
) for n in range(2, int(x) + 1)]))
return result
def c(x):
"""
Returns x if b(x) is not equal to 0, else returns None
Args:
x (Real): A real, whole number to evaluate.
Returns:
prime number values of x
"""
if b(x) != 0:
return x
else:
return None
if __name__ == '__main__':
# the first number to check for primality
start = 2
# the last number to check for primality plus one
end = 100
# list for text file
results = []
# loop through values of x and form list
for x in range(start, end):
cx = c(x)
bx = b(x)
#if cx is not None:
#print("c({}) = {}".format(x, cx))
print("b({}) = {}".format(x, bx))
# results.append("c({}) = {}\n".format(x, cx))
# # write list to file
# with open("prime_list_output.txt", "w") as f:
# f.writelines(results)