Python easy to understand solution


#1
import math
class Solution:
    # @param A : integer
    # @return a list of integers
    def allFactors(self, A):
        ans = list()
        if A == 0:
            ans.append(0)
            return ans
        if A == 1:
            ans.append(1)
            return ans
        if A == 2:
            ans.append(1)
            ans.append(2)
            return ans
        if A > 2:    
            ans.append(1)
            i = 2
            while i <= A**0.5:
                if A%i == 0:
                   # if i not in ans:
                    ans.append(i)
                   # if A/i not in ans:
                    if i != A**0.5:
                        ans.append(A/i)
                i += 1
            ans.append(A)
        return sorted(ans)