Last active
August 29, 2015 14:11
-
-
Save ssanin82/d5447731c3be9197e7a3 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
def ifactors(n): | |
if n <= 0 : | |
return | |
yield 1 | |
i = 2 | |
while i * i < n: | |
if n % i == 0: | |
yield i | |
yield n / i | |
i += 1 | |
if i * i == n : | |
yield i | |
if n > 1: | |
yield n |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment