From c80fb6f2a64e3bf21c62ff9cae9165dd8c8410aa Mon Sep 17 00:00:00 2001 From: MitchellHansen Date: Fri, 22 Jan 2016 00:47:14 -0800 Subject: [PATCH] modified: problem_3.py --- problem_3.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/problem_3.py b/problem_3.py index e69de29..e08cf2c 100644 --- a/problem_3.py +++ b/problem_3.py @@ -0,0 +1,20 @@ +import math + +highest_factor = 1 + +for x in range(3, int(math.sqrt(600851475143)), 2): + if 600851475143 % x == 0: + + prime = True + i = 3 + while i * i < x: + if x % i == 0: + prime = False # found a factor, not prime + break + else: + i += 2 + + if prime: + highest_factor = x + +print(highest_factor) \ No newline at end of file