-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path3.py
More file actions
26 lines (22 loc) · 650 Bytes
/
3.py
File metadata and controls
26 lines (22 loc) · 650 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
import math
def findFactor(num):
end = math.ceil(math.sqrt(num))
boolean = False
for i in range(2,end):
if num % i == 0:
largestFactor = num//i
boolean = checkPrime(largestFactor)
if boolean == True:
return largestFactor
for index in range(end+1,2,-1):
if num % index == 0:
boolean = checkPrime(index)
if boolean == True:
return index
def checkPrime(num):
for n in range(2, num):
if num % n == 0:
return False
return True
largestPrimeFactor = findFactor (600851475143)
print(largestPrimeFactor)