All pastes #812200 Raw Edit

Anonymous

public text v1 · immutable
·published 2007-12-11 16:23 UTC
rendered paste body
// A program that manually lists all the prime numbers upto specified max

#include <iostream>
using namespace std;

bool prime(int input, int max)
{
  //  return true;
    int result; // 
    int n = 2;        //
    while(n < input) {  // 
         result = input % n; // 
         if (result = 0) { return false; } // 
         ++n; //
                              }
    if (n = input ) { return true; } //if 3 = 3 give true.
}

int main()
{
    int max; // In example: = 14
    cout << "Enter max: ";
    cin >> max;
    int input = 3; 
    cout << "2 is prime\n"; 
    while (input < max + 1) {    // while 3 < 15
         bool end = prime(input, max); // prime ( 3, 14)
                if (end = false) { cout << input <<" is not prime\n"; }
                else { cout << input << " is prime\n";}
                ++input;
                       }      
system("PAUSE");      
}