Max Alekseyev on Fri, 28 Oct 2022 22:26:25 +0200

[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

unordered but memory-friendly fordiv() (without calling to divisors())

Can we have a variant of fordiv() / fordivfactored() that will not call to divisors() but generate the divisors on-fly at the cost of not enforcing them be in order?
The problem with divisors() is that it stores all the divisors in memory, which may be quite expensive, while this is only needed only if one wants to iterate over the divisors in order. If order of divisors is not important, then there is no need to store them all and thus save memory.

And having parfordiv() would be also a valuable addition.

PS. I realize that I can generate divisors manually via forvec() or alike, but it'd be really nice to have it as a built-in feature.

Thank you!