I'm sorry that I really don't understand your algorithm, but if you are interested in finding factors of the number, you could (based on your algorithm):
no = 2500 factors = [i for i in range(1,no) if no % i == 0] count = len(factors)
In this example, the factors will contain the following list:
[1, 2, 4, 5, 10, 20, 25, 50, 100, 125, 250, 500, 625, 1250]
In particular, for a prime number, the counter will be 1.
Edit: Good, so I misunderstood the question. The list contains only delimiters, not the main factors ... Sorry for the confusion!
source share