View Code of Problem 31

#include<cstdio>
 
int main(){
	long int k,ans;
	//freopen("31.txt","r",stdin);
	while(scanf("%ld",&k)!=EOF){
		int i=1;
		while(k>0){
			if(i%3==2&&i%5==3&&i%7==2){
				ans=i;			
				k--;
				i++;	
			}
			else	i++;			
		}
	printf("%ld\n",ans);
	}
	return 0;
}

Double click to view unformatted code.


Back to problem 31