Thread: Prime numbers

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User
    Join Date
    Apr 2002
    Posts
    26

    Question Prime numbers

    I am required to write a program which writes all the prime numbers between 1 and 10000, my only problem is that I cant find a way to determine the prime numbers from the rest! plz help! im not good at maths!

    I wrote the following:

    #include <stdio.h>
    int prime (int);
    int main ()
    {
    int i;
    prime (i);
    return 0;
    }

    int prime (int i)
    {
    i=1;
    while ( i <=1000) {

    if ( i % 2 == 1 && i % 3 == 1)
    printf ("%d\n",i);
    i++;
    }
    return i;
    }
    Last edited by Lazy Student; 05-13-2002 at 03:18 PM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Logical errors with seach function
    By Taka in forum C Programming
    Replies: 4
    Last Post: 09-18-2006, 05:20 AM
  2. Replies: 18
    Last Post: 11-04-2005, 02:41 PM
  3. prime numbers, counters, help!
    By vege^ in forum C++ Programming
    Replies: 1
    Last Post: 03-10-2003, 04:32 PM
  4. More Prime Numbers
    By mmuhlenb in forum C Programming
    Replies: 3
    Last Post: 02-21-2003, 10:06 AM
  5. Homework help
    By Jigsaw in forum C++ Programming
    Replies: 2
    Last Post: 03-06-2002, 05:56 PM