-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathrsa_python
More file actions
executable file
·34 lines (25 loc) · 810 Bytes
/
rsa_python
File metadata and controls
executable file
·34 lines (25 loc) · 810 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
29
30
31
32
33
34
#!/usr/bin/python3
from sys import argv
from math import sqrt
class factor_file:
def __init__(self, filename):
if filename is not None:
self.filename = filename
def read_test_file(self):
with open(self.filename, encoding="utf-8") as file:
lines = file.readlines()
number_to_factor = []
for line in lines:
number_to_factor.append(int(line))
return number_to_factor
def find_numbers(self, n):
for i in range(2, n):
if n == ((n // i) * i):
print("{}={}*{}".format(n, (n // i), i))
break
def factors(self):
ls = self.read_test_file()
for n in ls:
self.find_numbers(n)
for i in range(1, len(argv)):
factor_file(argv[i]).factors()