Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Divisors of a number?

Senuka Harbinger
A-Life, one bit at a time
Join date: 24 Oct 2005
Posts: 491
01-05-2007 15:29
What's a good memory efficient way to get all the divisors of a number? right now I'm looking at performing a 'for' loop and check each integer between 1 and the number I'm putting in and storing the divisors into a list, but for large numbers this is slow and/or causes stack heaps.
_____________________
My SLExchange shop

Typos are forgiven; desecrating the english language with reckless abandon and necrophilic acts is not.


The function is working perfectly fine. It's just not working the way you wanted it to work.
Newgate Ludd
Out of Chesse Error
Join date: 8 Apr 2005
Posts: 2,103
01-05-2007 15:52
Take a look here
Senuka Harbinger
A-Life, one bit at a time
Join date: 24 Oct 2005
Posts: 491
01-05-2007 16:14
ah, I forgot about that basic theorem of divisor pairs having one that is less than (or equal to) the square root of the number.
_____________________
My SLExchange shop

Typos are forgiven; desecrating the english language with reckless abandon and necrophilic acts is not.


The function is working perfectly fine. It's just not working the way you wanted it to work.