View Code of Problem 119

#include<iostream>
#include <math.h>
using namespace std;
int isPrime(long n) {
	if (n < 3) return n < 3;
	for (long i = 2; i < sqrt(n); ++i) {
		if (n % i == 0) return 0;
	}
	return 1;
}
int main()
{
	long n;
	int k = 1;
	while (cin >> n) {
		if (isPrime(n))
			cout << "Case #" << k << ": I'm richer than any one" << endl;
		else
			cout << "Case #" << k << ": What a fxcking day" << endl;
			++k;
	}
	return 0;
}

Double click to view unformatted code.


Back to problem 119