Finding all divisors of a number optimization

后端 未结 4 1889
一个人的身影
一个人的身影 2020-12-15 01:59

I have written the following function which finds all divisors of a given natural number and returns them as a list:

def FindAllDivisors(x):
    divList = []         


        
4条回答
  •  情深已故
    2020-12-15 02:50

    I don't know if there's much of a performance hit, but I'm pretty sure that cast to an int is unnecessary. At least in Python 2.7, int x / int y returns an int.

提交回复
热议问题