Created
December 5, 2014 10:11
-
-
Save veiset/39ed75589ab3a4a0800e to your computer and use it in GitHub Desktop.
This file contains 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
from itertools import permutations | |
def largestPrimeFactor(n, i=2): | |
while i * i <= n: | |
i, n = (i+1, n) if n % i else (i, n//i) | |
return n | |
print min([largestPrimeFactor(int("".join(n))) for n in permutations("123456789")]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Her kan du slippe unna med å sjekke på i=2 èn gang og bare for odds i loopen :)