View Code of Problem 31

#include <iostream>
using namespace std;

int main(){
  long int k,count;
  while(scanf("%ld",&k)!=EOF){
    count = 0;
    for(int j = 1;;j++){
      if(j%3==2 && j%5==3 && j%7==2){
        count ++;
        if(count==k){
          printf("%d\n",j);
          break;
        }
      }
    }
  }
  return 0;
}

Double click to view unformatted code.


Back to problem 31