Return to Snippet

Revision: 1292
at September 27, 2006 10:27 by gdonald


Updated Code
#include <iostream>
using namespace std;

int main()
{
    int i, j;
    
    for ( i = 2; i < 100000; i++ )
    {
        for ( j = 2; j <= i/2; j++ )
        {
            if ( ! ( i % j ) ) break;
        }
        
        if ( j > i / 2 ) cout << i << endl;
    }
    
    return 0;
}

Revision: 1291
at September 27, 2006 10:27 by gdonald


Initial Code
#include <iostream>
using namespace std;

int main()
{
    int i, j;
    
    for ( i = 2; i < 100000; i++ )
    {
        for ( j = 2; j <= i/2; j++ )
        {
            if ( ! ( i % j ) ) break;
        }
        
        if ( j > i / 2 ) cout << i << endl;
    }
    
    return 0;
}

Initial URL

                                

Initial Description

                                

Initial Title
C++ prime number generator

Initial Tags
number

Initial Language
C++