Clean-up
This commit is contained in:
34
src/Python/Problems001-050/Problem003.py
Normal file
34
src/Python/Problems001-050/Problem003.py
Normal file
@@ -0,0 +1,34 @@
|
||||
#!/usr/bin/env python3
|
||||
"""
|
||||
Created on 18 Mar 2017
|
||||
|
||||
@author: David Doblas Jiménez
|
||||
@email: daviddoji@pm.me
|
||||
|
||||
Solution for problem 3 of Project Euler
|
||||
https://projecteuler.net/problem=3
|
||||
"""
|
||||
|
||||
from utils import timeit
|
||||
|
||||
|
||||
@timeit("Problem 3")
|
||||
def compute():
|
||||
"""
|
||||
The prime factors of 13195 are 5, 7, 13 and 29.
|
||||
|
||||
What is the largest prime factor of the number 600851475143 ?
|
||||
"""
|
||||
ans = 600851475143
|
||||
factor = 2
|
||||
while factor * factor < ans:
|
||||
while ans % factor == 0:
|
||||
ans = ans // factor
|
||||
factor += 1
|
||||
|
||||
return ans
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
print(f"Result for problem 3: {compute()}")
|
||||
Reference in New Issue
Block a user