View Code of Problem 80

#include<stdio.h>
int a[10000000];
int main(){
    int N;
    scanf("%d",&N);
    while(N!=0){
        int x = N;
        for(int i = 1; i <= N; i++){
            a[i] =i;
        }
        for(int j = 1; x != 1; j++){
            if(j % 3 != 0){
                a[++N] = a[j];
            }
            else {
                x--;
            }
        }
        printf("%d\n",a[N]);
        scanf("%d",&N);
    }
    return 0;
}

Double click to view unformatted code.


Back to problem 80