algorithm to find in a number its divisors python


This Content is from Stack Overflow. Question asked by carel p.

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:

But then you have to loop throu all the numbers. Is there a better approach?


This question is not yet answered, be the first one who answer using the comment. Later the confirmed answer will be published as the solution.

This Question and Answer are collected from stackoverflow and tested by JTuto community, is licensed under the terms of CC BY-SA 2.5. - CC BY-SA 3.0. - CC BY-SA 4.0.

people found this article helpful. What about you?