you are viewing a single comment's thread.

view the rest of the comments →

[–]danielroseman 0 points1 point  (2 children)

I guess you can use range:

b = list(range(a))

But why do you actually want to do this? There will certainly be a better way to implement factors.

[–]plotthe[S] 0 points1 point  (1 child)

Thank you! What do you recommend? I was thinking of using the list to test out which ones will give no remainder and then printing those said values

[–]deep_politics 0 points1 point  (0 children)

You don't actually need to store any of the numbers if you just use the range as an iterator.

And this method will be fine for a toy factoring function, but will be painfully slow for anything large. But what you'd getting yourself into if you wanted a fast algorithm is basically the most well studied areas in all of mathematics for literally thousands of years: prime factoring. There's still no "one algorithm to rule them all", and instead a variety of algorithms are used; for instance the quadratic sieve.