All pastes #340806 Raw Edit

Unnamed

public cpp v1 · immutable
·published 2007-02-05 01:07 UTC
rendered paste body
#include <vector>#include <cmath>using std::vector;vector<int> list;bool isPrime(int nNum);int main() {	int thisNumber;	for(int i = 2; list.size() < 1000000; ++i) {		thisNumber = i;		if(isPrime(thisNumber)) {			list.push_back(thisNumber);		}	}}bool isPrime(int nNum) {	int maxFactor = int(sqrt(nNum)), thisFactor;	bool bRetVal = true;	for(int i = 0; i < list.size(); ++i) {		thisFactor = list[i];		if(thisFactor > maxFactor) {			break;		}		if(nNum % thisFactor == 0) {			bRetVal = false;			break;		}	}	return bRetVal;}