View Code of Problem 119

#include<iostream>
#include<cmath>

using namespace std;

bool isPrime(int n) {
	if (n == 1) {
		return true;
	}
	for (int i = 2; i < sqrt(n); ++i) {
		if (n % i == 0) {
			return false;
		}
	}
	return true;
}

int main() {
	int i = 0;
	int N;
	while (cin >> N) {
		cout << "Case #" << ++i << ": ";
		if (isPrime(N)) {
			cout << "I'm richer than any one";
		}
		else {
			cout << "What a fxcking day";
		}
		cout << endl;
	}
}

Double click to view unformatted code.


Back to problem 119