Python simple program


#1

class Solution:
# @param A : integer
# @return a list of integers
def allFactors(self, A):
k=[]
import math
sr=math.sqrt(A)

    if A==1 or A==0:
        return [1]
    if(sr-math.floor(sr)!=0):
        for i in range(1,int(math.sqrt(A))+1):
            if A%i==0:
                k.append(i)
                if i!=int(math.sqrt(A)):
                    k.append(A/i)
                if i== int(math.sqrt(A)):
                    if A%i==0:
                        k.append(A/i)
    else:
        for i in range(1,int(math.sqrt(A))+1):
            if A%i==0:
                k.append(i)
                if i!=int(math.sqrt(A)):
                    k.append(A/i)
        
    k.sort() 
    return(k)