All pastes #29281 Raw Edit

Unnamed

public text v1 · immutable
#29281 ·published 2005-11-19 17:35 UTC
rendered paste body
#include <fstream>
#include <iostream>
#include <string>
using namespace std;

bool prime (unsigned int num)
{
   if (num % 2 == 0) { return false; }
   for (unsigned int chk = 3; chk <= sqrt(num); chk += 2)
   {
      if (num % chk == 0) { return false; }
   }
   return true;
}

int main()
{
   string fdump;
   system("CLS");
   cout << "Welcome to Gravisoft's Prime Number Generator\n";
   /* cout << "Dump path: (Default C:\\prime.txt)\n"
   getline(cin,fdump); */
   for (unsigned int tochk = 3;;tochk += 2)
   {
      if (prime(tochk)) { cout << tochk << endl; }
   }
   return 0;
}