determining if a # is prime

This is a discussion on determining if a # is prime within the C++ Programming forums, part of the General Programming Boards category; see the topic nothing too advanced... im only up to looping. if statements and variables...

  1. #1
    Unregistered
    Guest

    determining if a # is prime

    see the topic

    nothing too advanced... im only up to looping. if statements and variables

  2. #2
    Registered User
    Join Date
    Feb 2002
    Posts
    591
    There was a good thread on this topic last week. please search the board

  3. #3
    UNBANNED OneStiffRod's Avatar
    Join Date
    Jan 2002
    Posts
    669
    isn't a prime an even number? so then it's divisible by 2...

    if(number%2==0){//If the number is divisible by 2 it will have a remainder of 0 and thus we call it prime, if it has a remainder then we call it (I forget the term)
    }
    else //everthing else, not prime numbers
    My Avatar says: "Stay in School"

    Rocco is the Boy!
    "SHUT YOUR LIPS..."

  4. #4
    Registered User
    Join Date
    Jan 2002
    Posts
    11
    Originally posted by OneStiffRod
    isn't a prime an even number? so then it's divisible by 2...

    if(number%2==0){//If the number is divisible by 2 it will have a remainder of 0 and thus we call it prime, if it has a remainder then we call it (I forget the term)
    }
    else //everthing else, not prime numbers
    No.

  5. #5
    Registered User
    Join Date
    Jan 2002
    Posts
    16
    Originally posted by OneStiffRod
    isn't a prime an even number? so then it's divisible by 2...

    if(number%2==0){//If the number is divisible by 2 it will have a remainder of 0 and thus we call it prime, if it has a remainder then we call it (I forget the term)
    }
    else //everthing else, not prime numbers
    Prime numbers are numbers that are only be divisible by 1 and themself.

    Anyway, that thread is right here
    http://www.cprogramming.com/cboard/s...ighlight=prime
    Last edited by _Will333_; 02-25-2002 at 09:26 PM.

    "I once saw a photograph of a large
    herd of wild elephants in Central
    Africa seeing an airplane for the first
    time, and all in a state of wild
    collective terror... As, however, there
    were no journalists among them, the
    terror died down when the airplane
    was out of sight. "


    - Bertrand Russell


Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Calculating prime factor of a huge number.
    By Bakster in forum C Programming
    Replies: 15
    Last Post: 02-20-2009, 12:06 PM
  2. prime number program with function
    By mackieinva in forum C Programming
    Replies: 17
    Last Post: 09-20-2007, 09:36 AM
  3. prime numbers, counters, help!
    By vege^ in forum C++ Programming
    Replies: 1
    Last Post: 03-10-2003, 04:32 PM
  4. Fast prime determining algorithm
    By Ken Fitlike in forum A Brief History of Cprogramming.com
    Replies: 0
    Last Post: 12-01-2002, 03:05 AM
  5. Homework help
    By Jigsaw in forum C++ Programming
    Replies: 2
    Last Post: 03-06-2002, 05:56 PM

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