Skip to content

Instantly share code, notes, and snippets.

@ssanin82
Last active August 29, 2015 14:11
Show Gist options
  • Save ssanin82/d5447731c3be9197e7a3 to your computer and use it in GitHub Desktop.
Save ssanin82/d5447731c3be9197e7a3 to your computer and use it in GitHub Desktop.
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