Thread: what going on....continued

  1. #1
    Unregistered
    Guest

    what going on....continued

    now how would we go about eliminating every third number as well, and continue with every 5, 7, 11, etc. numbers, to be left with all of the prime numbers. We figured out how to eliminate the evens, but we have to go on from there, and print out only the prime numbers.
    i.e., start with #'s 1-100, eliminate multiple of 2, the 3, then 5, then 7, until we are left with only the prime numbers from 1 to (n).

    IF YOU HAVE NO IDEA WHAT I'M TALKING ABOUT, PLEASE READ THE THREAD TITLED:
    whats going onm

    thank you

  2. #2
    Unregistered
    Guest
    if the goal is to print out only the nodes that have prime numbers stored as data or only nodes whose sequence number is prime, then why not just create a function to check if a number is prime, then search the list from top to bottom evaluating the appropriate "number" for "primeness", and if it's prime print it out, if not move on to the next node. The elimination process seems fraught with problems.

  3. #3
    Skunkmeister Stoned_Coder's Avatar
    Join Date
    Aug 2001
    Posts
    2,572
    the algorithm you are using to find primes is called the sieve of erastophenes(sp some old greek geezer). Look it up on google and you will find many examples.
    Free the weed!! Class B to class C is not good enough!!
    And the FAQ is here :- http://faq.cprogramming.com/cgi-bin/smartfaq.cgi

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Classes Continued.
    By Aliaks in forum C++ Programming
    Replies: 28
    Last Post: 07-06-2009, 08:05 AM
  2. Continued issues with Winows Errors when running program
    By hpteenagewizkid in forum C Programming
    Replies: 6
    Last Post: 11-14-2006, 03:51 PM
  3. Oil debate continued
    By axon in forum A Brief History of Cprogramming.com
    Replies: 5
    Last Post: 07-24-2004, 02:22 AM
  4. Translator continued
    By edshaft in forum C++ Programming
    Replies: 1
    Last Post: 05-09-2003, 10:03 PM
  5. error detection continued
    By nas in forum C Programming
    Replies: 3
    Last Post: 06-21-2002, 10:35 PM