示例#1
0
def devFactor(num):
    factors = e8_5.getfactors(num)
    if len(factors)>2:
        for i in factors:
            if e8_4.isprime(i) and i > 1:
                return [i]+devFactor(num/i) #[i].append(devFactor(num/i)) return None because append() did not new one list
    else:
        return [num]
示例#2
0
def devFactor(num):
    factors = e8_5.getfactors(num)
    if len(factors) > 2:
        for i in factors:
            if e8_4.isprime(i) and i > 1:
                return [i] + devFactor(
                    num / i
                )  #[i].append(devFactor(num/i)) return None because append() did not new one list
    else:
        return [num]
示例#3
0
def isPerfect(num):
    if num < 1:
        return 0
    factors = e8_5.getfactors(num)
    factors.remove(num)
    sumx = 0
    for x in factors:
        sumx += x
    if sumx == num:
#         print "%d:%s"%(num,str(factors))
        return 1
    else:
        return 0
示例#4
0
def isPerfect(num):
    if num < 1:
        return 0
    factors = e8_5.getfactors(num)
    factors.remove(num)
    sumx = 0
    for x in factors:
        sumx += x
    if sumx == num:
        #         print "%d:%s"%(num,str(factors))
        return 1
    else:
        return 0