How do I print out all prime factors in C and all the distinct prime factors of the i

This is a discussion on How do I print out all prime factors in C and all the distinct prime factors of the i within the C Programming forums, part of the General Programming Boards category; How do I print out all prime factors in C and all the distinct prime factors of the inputted number. ...

  1. #1
    Registered User
    Join Date
    Feb 2009
    Posts
    1

    Question How do I print out all prime factors in C and all the distinct prime factors of the i

    How do I print out all prime factors in C and all the distinct prime factors of the inputted number. when a user enter a number less 2000. The user should be prompted to enter another number until the user wishes to quit.

  2. #2
    Registered User
    Join Date
    Dec 2006
    Location
    Canada
    Posts
    3,181

  3. #3
    Super Moderator
    Join Date
    Sep 2001
    Posts
    4,913
    -Duplicate threads removed and renamed-

    Take your best shot at it. If it doesn't work, post your source code, and details of what went wrong and what you need help with.

  4. #4
    spurious conceit MK27's Avatar
    Join Date
    Jul 2008
    Location
    segmentation fault
    Posts
    8,300
    The way I did it was to seed an array with the first few primes and then use a "divide by prime" scheme that built up the array dynamically to include higher primes. I managed to get it to match up to a few million then lost interest in prime numbers.
    C programming resources:
    GNU C Function and Macro Index -- glibc reference manual
    The C Book -- nice online learner guide
    Current ISO draft standard
    CCAN -- new CPAN like open source library repository
    3 (different) GNU debugger tutorials: #1 -- #2 -- #3
    cpwiki -- our wiki on sourceforge

Popular pages Recent additions subscribe to a feed

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21