help me

This is a discussion on help me within the C Programming forums, part of the General Programming Boards category; I would like to know how to write a small function to get prime number , actually to check it ...

  1. #1
    Registered User
    Join Date
    Nov 2001
    Posts
    2

    help me

    I would like to know how to write a small function to get prime number , actually to check it .
    thank U

  2. #2
    * Death to Visual Basic * Devil Panther's Avatar
    Join Date
    Aug 2001
    Posts
    768

    Cool

    if i remember correctly, a prime number is a number that div only by itself and one...

    Code:
    int (int num) {
      if ((num==2)||(num==3)||(num==5)||(num==7)||((num%2)&&(num%3)&&(num%5)&&(num%7)))
      return(1); 
     else return(0);
    }
    Last edited by Devil Panther; 11-18-2001 at 09:58 AM.

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