View Code of Problem 31

#include<bits/stdc++.h>
using namespace std;

int main() {
    int k;
    while (cin>>k){
        int num[100];
        int i=1;
        int z=0;
        while (1){
            if (z>k)
                break;
            if (i%3==2&&i%5==3&&i%7==2)
                num[z++]=i;
            i++;
        }
        cout<<num[k-1]<<endl;
    }

    return 0;
}

Double click to view unformatted code.


Back to problem 31