Factors of an integer: Difference between revisions

Line 1,453:
 
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
>>> def factor(n):
factors = set()
Anonymous user