-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfind_a_factor
executable file
·64 lines (56 loc) · 2.88 KB
/
find_a_factor
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
61
62
63
64
#!/usr/bin/env python
import os
import sys
import time
from FindAFactor import find_a_factor, FactoringMethod
def main():
argv_len = len(sys.argv)
to_factor = 12953359405011071899
method=FactoringMethod(int(os.environ.get('FINDAFACTOR_METHOD'))) if os.environ.get('FINDAFACTOR_METHOD') else FactoringMethod.PRIME_PROVER
node_count=int(os.environ.get('FINDAFACTOR_NODE_COUNT')) if os.environ.get('FINDAFACTOR_NODE_COUNT') else 1
node_id=int(os.environ.get('FINDAFACTOR_NODE_ID')) if os.environ.get('FINDAFACTOR_NODE_ID') else 0
gear_factorization_level=int(os.environ.get('FINDAFACTOR_GEAR_FACTORIZATION_LEVEL')) if os.environ.get('FINDAFACTOR_GEAR_FACTORIZATION_LEVEL') else 23
wheel_factorization_level=int(os.environ.get('FINDAFACTOR_WHEEL_FACTORIZATION_LEVEL')) if os.environ.get('FINDAFACTOR_WHEEL_FACTORIZATION_LEVEL') else 13
sieving_bound_multiplier=float(os.environ.get('FINDAFACTOR_SIEVING_BOUND_MULTIPLIER')) if os.environ.get('FINDAFACTOR_SIEVING_BOUND_MULTIPLIER') else 1.0
smoothness_bound_multiplier=float(os.environ.get('FINDAFACTOR_SMOOTHNESS_BOUND_MULTIPLIER')) if os.environ.get('FINDAFACTOR_SMOOTHNESS_BOUND_MULTIPLIER') else 1.0
gaussian_elimination_row_offset=int(os.environ.get('FINDAFACTOR_GAUSSIAN_ELIMINATION_ROW_OFFSET')) if os.environ.get('FINDAFACTOR_GAUSSIAN_ELIMINATION_ROW_OFFSET') else 1
check_small_factors=True if os.environ.get('FINDAFACTOR_CHECK_SMALL_FACTORS') else False
if argv_len > 1:
to_factor = int(sys.argv[1])
if argv_len > 2:
method = FactoringMethod(int(sys.argv[2]))
if argv_len > 3:
node_count = int(sys.argv[3])
if argv_len > 4:
node_id = int(sys.argv[4])
if argv_len > 5:
gear_factorization_level = int(sys.argv[5])
if argv_len > 6:
wheel_factorization_level = int(sys.argv[6])
if argv_len > 7:
sieving_bound_multiplier = float(sys.argv[7])
if argv_len > 8:
smoothness_bound_multiplier = float(sys.argv[8])
if argv_len > 9:
gaussian_elimination_row_offset = int(sys.argv[9])
if argv_len > 10:
check_small_factors = sys.argv[10] not in ['False', '0']
start = time.perf_counter()
result = find_a_factor(
to_factor,
method = method,
node_count=node_count,
node_id=node_id,
gear_factorization_level=gear_factorization_level,
wheel_factorization_level=wheel_factorization_level,
sieving_bound_multiplier=sieving_bound_multiplier,
smoothness_bound_multiplier=smoothness_bound_multiplier,
gaussian_elimination_row_offset=gaussian_elimination_row_offset,
check_small_factors=check_small_factors
)
print(time.perf_counter() - start)
print(str(result) + " * " + str(to_factor // result) + " == " + str(to_factor))
print((result * (to_factor // result)) == to_factor)
return 0
if __name__ == '__main__':
sys.exit(main())