Python code O(sqrt(n)) solution


#1

import math
class Solution:
# @param A : integer
# @return a list of integers
def allFactors(self, A):
list_a = set()
range_a= math.ceil(math.sqrt(A))+1
range_sqrt= math.sqrt(A)
for i in range(1,range_a):
if A%i==0:
list_a.add(i)
if i!=range_sqrt :
list_a.add(int(A/i))
return sorted(list(list_a))