Moderators: Darobat, RecursiveS, Dante Shamest, Bugdude, Wizard
/*
* Name: Prime number generator
* Copyright: Nope, it's free
* Author: Mohsen A.
* Date: 05/8/03
* Description: The name says it all
*/
#include <iostream>
#include <iomanip>
#include <fstream>
#include <cmath>
using namespace std;
int main () {
long double loopCounter;
long double primeCounter = 1;
long double primeNumber = 2;
long double numberCounter = 1;
bool itsPrime = true;
ofstream file;
file.setf(ios::fixed);
file.precision(0);
cout.setf(ios::fixed);
cout.precision(0);
file.open("PrimeNumbers.txt");
file << '1' << endl;
cout << "Starting generation of prime numbers" << endl;
cout << "====================================" << endl;
while ( primeNumber > 0 ) {
for ( loopCounter = 2; loopCounter < primeNumber; loopCounter++ ) {
if ( fmodl(primeNumber, loopCounter) == 0 ) {
itsPrime = false;
break;
}
}
if ( itsPrime ) {
file << primeNumber << endl;
cout << primeNumber << setw(5) << " is a primeNumber." << endl;
primeCounter++;
//cout << primeCounter << setw(5) << " primes generated so far." << endl;
}
itsPrime = true;
primeNumber++;
numberCounter++;
}
file.close();
return 0;
}MOHSEN wrote:Chances are GIMPS (Great Internet Mercenary Prime Search) has already found that number. The largest known prime number as of now is about 10 million digits long![]()
Look them up, if you find the next prime number with 10 million digits you could win $100,000, they give you the software and the number, all you gotta do is run it on your computer and see if it infact is a prime. That dude there is BSing
foelock wrote:I hope this help
But most likely it will die with me…
Paul
Users browsing this forum: No registered users and 0 guests