Thread: primes

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User
    Join Date
    Mar 2002
    Posts
    4

    primes

    hello everyone.

    the is a real pain in the neck...can anyone help me write a program that determines all the preimes from 1 to 1000 , counts them, and determine if any of the primes are carmuichael numbers...i donot know what the hell they are !!

    HELP !!!!

    i got this program from a friend but it only calculates the primes up to 100, how do i extend it to 1000 ??

    #include <iostream.h>


    void main(){
    //declarations
    int var1;
    int var2;
    int flag;
    //tells that the user will see all the prime numbers up too 100
    cout << "All of the prime numbers up to 100 are...\n";
    //calculations


    for(var1 = 2; var1 <= 100; var1++){
    flag = 1;


    for(var2 = 2; var2 < var1; var2++){


    if((int)var1 % (int)var2 == 0){
    flag = 0;
    }
    }
    //output...


    if(flag == 1){
    cout << var2;
    cout << " ";
    }
    }
    cout << " ";
    }
    Last edited by godfather; 05-08-2002 at 02:32 AM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Messene Primes
    By mrsirpoopsalot in forum C++ Programming
    Replies: 9
    Last Post: 01-31-2009, 10:32 PM
  2. Finding primes
    By scwizzo in forum C++ Programming
    Replies: 11
    Last Post: 09-10-2008, 06:15 PM
  3. primes program need some help
    By Mshock in forum C Programming
    Replies: 2
    Last Post: 04-17-2006, 07:21 PM
  4. a program that writes the primes
    By Geo-Fry in forum C++ Programming
    Replies: 8
    Last Post: 03-29-2003, 06:37 PM
  5. Generating Primes !?!?!?!
    By Moni in forum C++ Programming
    Replies: 12
    Last Post: 03-16-2003, 07:22 AM