Newbie here plz help!

This is a discussion on Newbie here plz help! within the C Programming forums, part of the General Programming Boards category; Hello guys and thanks for your time... i'm having a difficulty in finding the prime numbers from 2 to n, ...

  1. #1
    Unregistered
    Guest

    Unhappy Newbie here plz help!

    Hello guys and thanks for your time...
    i'm having a difficulty in finding the prime numbers from 2 to n, where n a number i enter...could you help me please?(well i'm not so good at maths i suppose!)
    thank you

  2. #2
    End Of Line Hammer's Avatar
    Join Date
    Apr 2002
    Posts
    6,231
    The ever friendly google should help ya:

    http://www.google.com/search?hl=en&q...+c+programming

    First page come up with a prog to do what you asked.
    When all else fails, read the instructions.
    If you're posting code, use code tags: [code] /* insert code here */ [/code]

  3. #3
    Used Registerer jdinger's Avatar
    Join Date
    Feb 2002
    Posts
    1,065
    Go here

    If that doesn't help, post your code so we can see which part you're having problems with.

  4. #4
    Just because ygfperson's Avatar
    Join Date
    Jan 2002
    Posts
    2,493
    here's the bfi method:
    PHP Code:
    int main() {
    int n=340/* some number */
    int count;
    for (
    count=2count ncount++)
      if (
    isprime(count))
       
    printf("%d is prime\n",count);
    return 
    0;
    }

    bool isprime(int y) {
    /*you figure this part out*/
    /*hint:
      check all integers from 2 to the square root of y plus 1
      if y mod n is 0, then return true
     else return false
    */




Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Newbie c programmer need assistance plz...
    By Nexus-ZERO in forum C Programming
    Replies: 17
    Last Post: 12-27-2007, 04:05 PM
  2. Newbie needs help plz
    By boffinson in forum C++ Programming
    Replies: 22
    Last Post: 07-29-2006, 04:25 AM
  3. im newbie to opengl, help plz
    By NecroFromHell in forum C++ Programming
    Replies: 4
    Last Post: 05-14-2006, 09:24 PM
  4. newbie reading a file..how? plz help
    By iori in forum C Programming
    Replies: 3
    Last Post: 04-09-2003, 04:58 PM
  5. HI .. newbie to the board... need some help plz
    By Arwen27 in forum C Programming
    Replies: 3
    Last Post: 04-28-2002, 08:27 AM

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