Skip to content

Instantly share code, notes, and snippets.

@mattliving
Created June 7, 2012 13:02
Show Gist options
  • Save mattliving/2888697 to your computer and use it in GitHub Desktop.
Save mattliving/2888697 to your computer and use it in GitHub Desktop.
Find the first factor of a number in Python
#!/usr/bin/env
def findfact(n):
for x in xrange(2,n+1):
if (n % x) == 0:
return x
return n
print findfact(11)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment