View Code of Problem 31

#include<iostream>
using namespace std;
int main() {
	long long k;
	while(scanf("%d",&k)!=EOF) {
		long long count=0, j=9, i=1; 
		while(1) {
			if(j%3==2&&j%5==3) {
				count++;
				if(count==k) break;
			}
			i++;
			j=7*i+2;
		}
		printf("%d\n",j);
	}
} 

Double click to view unformatted code.


Back to problem 31