Thread: Help with Computing Divisors

  1. #1
    Registered User
    Join Date
    May 2004
    Posts
    4

    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?
    Last edited by MrPink; 09-30-2005 at 06:25 PM. Reason: resloved some issues

  2. #2
    ^ Read Backwards^
    Join Date
    Sep 2005
    Location
    Earth
    Posts
    282
    Witness the awesome power of the internet (and google).
    http://forums.devarticles.com/archiv...-prime-factors

    Should get ya started.

  3. #3
    Registered User
    Join Date
    May 2004
    Posts
    4

    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...
    Last edited by MrPink; 09-30-2005 at 08:00 PM. Reason: mis-spell

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. display of divisors
    By Lissa in forum C++ Programming
    Replies: 3
    Last Post: 10-19-2008, 11:20 AM
  2. Finding divisors
    By xbusterx in forum C++ Programming
    Replies: 20
    Last Post: 10-04-2008, 08:08 PM
  3. Computing Degree Question
    By cjwenigma in forum A Brief History of Cprogramming.com
    Replies: 2
    Last Post: 09-17-2007, 01:06 PM
  4. small Distributed computing utilies
    By vinit in forum C Programming
    Replies: 2
    Last Post: 04-17-2006, 03:37 AM
  5. Find integer 1- 1000 w/ most divisors w/o remainder
    By AlexDeToi in forum C++ Programming
    Replies: 3
    Last Post: 03-24-2002, 08:45 PM