algorithm to find in a number its divisors python

Viewed 15

What would be the best python approach to find all the divisors of a number?

Of course you can do something like:

for i in n:
     if n/i !=0:
          print(i)

But then you have to loop throu all the numbers. Is there a more efficient algorithm (which takes less time and memory) that I can use that you don't need to loop in all the numbers of N but only in a part?

0 Answers
Related