[ create a new paste ] login | about

Link: http://codepad.org/HKpmsxHH    [ raw code | output | fork ]

C++, pasted on Sep 10:
#include <iostream>
#include <math.h>
using namespace std;

int limit = 13195;

int IsPrime(int test);

int main(void) {
	int num;
	for (num = 2; num < ceil(sqrt((double)limit)); num++) {
		if (!(num % 2 || num % 3 || num % 5 || num % 7)) {
		}
		
		else if (IsPrime(num) && (!(limit % num))) {
			cout << num << endl;
		}
	}

	return 0;
}

int IsPrime(int test) {
	for (int i = 2; i <= test; i++) {
		if (test % i) { //test % i != 0
			return 1;
		}

		return 0;
	}
}


Output:
1
2
3
cc1plus: warnings being treated as errors
In function 'int IsPrime(int)':
Line 31: warning: control reaches end of non-void function


Create a new paste based on this one


Comments: