Created
January 4, 2020 22:07
-
-
Save nspool/2e534b11a03fef08c693d7238ef5710a to your computer and use it in GitHub Desktop.
Euler 3
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
s = 0 | |
def fib(x,y): | |
if y < 4000000: | |
if y % 2 == 0: | |
global s | |
s = s + y | |
v = fib(y, x + y) | |
return v | |
else: | |
return 0 | |
def largest_prime_factor(n): | |
# Make it odd (cheating!) | |
p = 775145 | |
# check that it divides n | |
while p > 1: | |
if (n % p) == 0: | |
q = p | |
i = (q - 1) / 2 | |
while q % i != 0: | |
i = i - 1 | |
if i == 1: | |
print('return q') | |
return q | |
p = p - 2 | |
print('return p') | |
return p | |
# def fmt(n): | |
n = 600851475143 | |
# n = 13195 | |
print(largest_prime_factor(n)) | |
# print(fmt(n)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment