View Code of Problem 31

#include<stdio.h>

#include<math.h>
	
int main(){

	int k;
	while(scanf("%d",&k)!=EOF)
	{
		if(k<0)return 0;
		int u=0;
		for(int i=3;i<100000;i++){
			if(i%3==2&&i%5==3&&i%7==2)u++;
			if(u==k){printf("%d\n",i);break;}
			
		
		}
	
	
	}
	


}

Double click to view unformatted code.


Back to problem 31