Created
June 7, 2012 13:02
-
-
Save mattliving/2888697 to your computer and use it in GitHub Desktop.
Find the first factor of a number in Python
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
| #!/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