def getNum(num): dict={}
#因子数都是以sqrt(num)为界对称的,找出<=sqrt(num)这边的,用num/i就同时获得了另一半的因子数,从1开始遍历即可。 for i in range(1,int(num**0.5)+1): if num%i==0: dict[i]=1 dict[num//i]=1 print(dict.keys())
def getNum(num): dict={}
#因子数都是以sqrt(num)为界对称的,找出<=sqrt(num)这边的,用num/i就同时获得了另一半的因子数,从1开始遍历即可。 for i in range(1,int(num**0.5)+1): if num%i==0: dict[i]=1 dict[num//i]=1 print(dict.keys())
原文:https://www.cnblogs.com/gczr/p/8367521.html