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]
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]
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