View Code of Problem 119

#include <iostream>
#include <math.h>
using namespace std;

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

int main(){
  int n,m=1;
  while(scanf("%d",&n)!=EOF){
    if(isprime(n))
      printf("Case #%d: I'm richer than any one\n",m);
    else
      printf("Case #%d: What a fxcking day\n",m);
  }
  return 0;
}

Double click to view unformatted code.


Back to problem 119