This commit is contained in:
David Doblas Jiménez
2021-09-20 17:53:15 +02:00
parent ad6c4e4cd2
commit 7c8165d9c2
50 changed files with 2264 additions and 0 deletions

View 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()}")