Skip to content

Instantly share code, notes, and snippets.

@veiset
Created December 5, 2014 10:11
Show Gist options
  • Save veiset/39ed75589ab3a4a0800e to your computer and use it in GitHub Desktop.
Save veiset/39ed75589ab3a4a0800e to your computer and use it in GitHub Desktop.
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")])
@thrandre
Copy link

thrandre commented Dec 5, 2014

Her kan du slippe unna med å sjekke på i=2 èn gang og bare for odds i loopen :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment