- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProblem3.py
More file actions
Latest commit
30 lines (21 loc) · 612 Bytes
/
Copy pathProblem3.py
File metadata and controls
30 lines (21 loc) · 612 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
"""
@author: mc-es
Problem 3
The prime factors of 13195 are 5, 7, 13 and 29.
What is the largest prime factor of the number 600851475143 ?
Answer: 6857
"""
importmath
number=600851475143
maxPrime=1
defisPrime(number):
isPrime=True
# A number is prime if it is not divisible by its square root.
foriinrange(2, int(math.sqrt(number) +1)):
ifnumber%i==0:
isPrime=False
returnisPrime
foriinrange(2, int(math.sqrt(number))):
ifnumber%i==0andisPrime(i):
maxPrime=i
print("Answer: "+str(maxPrime))