View Code of Problem 119

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

Double click to view unformatted code.


Back to problem 119