All pastes #2081698 Raw Edit

Untitled

public cpp v1 · immutable
#2081698 ·published 2011-09-21 01:01 UTC
rendered paste body
//Erin O'Toole//Prime Finder V2 (Two Steps + some loop changes)#include <iostream>#include <fstream>#include <cmath>int is_prime(int);using namespace std;int main(){	cout << "Prime Calculator 2.0" << endl;	cout << "Enter the max number you'd like to calculate" << endl;	int to_check, counter = 3;	cin >> to_check;		if ((to_check == 2) || (to_check == 1))	{		cout << to_check << ": is a prime" << endl;	}		for (int counter = 1; counter <= to_check; counter++)	{				if (is_prime(counter) == 1)		{			cout << counter << ": is a prime" << endl;		}		else if (is_prime(counter) == 0)		{			//cout << counter << ": is not prime" << endl;		}		else		{			cout << "error sqrt = " << sqrt(to_check) << endl;		}	}	cin >> to_check;	return 0;}	int is_prime(int viable){	int count = viable - 1;	while (count > 1)	{		if ((viable % count) == 0)		{			return 0;		}		else		{			count--;		}	}		return 1;}