All pastes #944058 Raw Edit

Anonymous

public text v1 · immutable
·published 2008-03-15 20:24 UTC
rendered paste body
/* 
Robert Gleeson
robert.gleeson3@gmail.com
prime.cpp
Generate a list of prime numbers starting @ 2 and ending @ users choice. 
*/ 

#include <iostream>
#include <math.h>

using namespace std;

int main()

	{
int max; // Variable for user input.

int divider = 3; // Variable to divide by.


cout << "Enter max : " ;
cin >> max;

for (int i = 2 ; i <= max; i++ )
{
cout << i << " % " << divider << " = " << i % divider << endl; // print the equation.


if(i % divider == 0) { divider++; } // i % divider == 0, not a prime/
else { cout << i << endl;} // prime number!
}

}