# Help with Computing Divisors

• 09-30-2005
MrPink
Help with Computing Divisors
I would like to compute the divisors and prime divisors of a user defined integer using a for loop in a function. Having a hard time deciding if it would be best to do this in a for loop? Any help would be appreciated!

Heres some review, if you need it... :(

A divisor is a number that divides into another number without a remainder. So I guess it would be the opposite of % modulus division...

A Prime divisor is the same thing, but the divisor must be prime. IE the divisor can only be divided by itself and 1.

I know the for loop would be something like this for divisors:

Code:

```for ( x=1; x<= i; x++ )  {       if (  x%i == 0 )```
Dont know what else to put in the If and I dont know how to do that for Prime divisors...Any ideas?
• 09-30-2005
Enahs
Witness the awesome power of the internet (and google).
http://forums.devarticles.com/archiv...-prime-factors

Should get ya started.
• 09-30-2005
MrPink
thanks
Thanks, that helped a lot...

By the way, what did you type into google for that to come up? I tried every combination of keywords I could think of and found nothing...