Thread: Find first 250 Prime Number

  1. #1
    Registered User
    Join Date
    Jan 2007

    Find first 250 Prime Number

    Hi Experts,

    I want to write a 'C' program to find the first 250 prime numbers and store
    them in an array and then print them out in columns on the screen.

    Can someone give me the coding if you already have it.



  2. #2
    pwns nooblars
    Join Date
    Oct 2005
    Portland, Or
    God I love when a semester is starting. See the homework FAQ. Why would you even consider taking a C class if you have no interest?

  3. #3
    Registered User
    Join Date
    Jan 2007
    Try implementing a solution; we will help you if you have any questions.

    I guess, you know what the prime number is.


  4. #4
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    The edge of the known universe
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  5. #5
    The larch
    Join Date
    May 2006
    Any number that is not prime, is evenly divisible by a prime number.

    So, mark 2 as the first prime and try dividing all the following (odd) numbers from 3 upwards with the primes you have found so far. If it cannot be divided by any without remainder, add it to the list of primes.

    Continue, until you have 250 primes in the list.

    (Optimisation: you don't have to test-divide with all primes, but up to the square root of the value you are currently testing.)

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. help, trying to find prime number
    By vampirekid.13 in forum C++ Programming
    Replies: 19
    Last Post: 05-02-2009, 03:29 PM
  2. prime number program with function
    By mackieinva in forum C Programming
    Replies: 17
    Last Post: 09-20-2007, 08:36 AM
  3. Prime Number stops after 29, but why?
    By Daveo in forum C Programming
    Replies: 22
    Last Post: 09-17-2004, 10:55 AM
  4. prime number.
    By tdoctasuess in forum C Programming
    Replies: 13
    Last Post: 05-13-2004, 08:03 AM
  5. Homework help
    By Jigsaw in forum C++ Programming
    Replies: 2
    Last Post: 03-06-2002, 05:56 PM