-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathproblem_003.py
More file actions
40 lines (36 loc) · 1.01 KB
/
Copy pathproblem_003.py
File metadata and controls
40 lines (36 loc) · 1.01 KB
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
import math
value = 600851475143
#value = 13195
# for i in range(2,math.ceil(value/2)):
# #print(i)
# if value % i == 0:
# factors.append(i)
# is_prime = True
# print("factors: ",factors)
# for j in range(2,math.ceil(i/2)):
# print(i,j)
# if i % j == 0:
# is_prime = False
# if is_prime == True:
# prime_factors.append(i)
# print("primes: ",prime_factors)
def check_factor(value):
factors = []
prime_factors = []
for i in range(2,math.ceil(value/2)):
if value % i == 0:
factors.append(i)
print(factors)
if is_prime(i):
prime_factors.append(i)
print(prime_factors)
value = value / i
if value == 1:
break
return factors, prime_factors
def is_prime(value):
for i in range(2,math.ceil(value/2+1)):
if value % i == 0:
return False
return True
print(check_factor(value))