Factors of an integer: Difference between revisions

Content added Content deleted
Line 1,453: Line 1,453:


Much better (realize that factors come in pairs, the smaller of which is no bigger than sqrt(n)):
Much better (realize that factors come in pairs, the smaller of which is no bigger than sqrt(n)):
<lang python>>>> from math import floor, sqrt
<lang python>>>> from math import sqrt
>>> def factor(n):
>>> def factor(n):
factors = set()
factors = set()