#include<bits/stdc++.h> using namespace std; int main(){ int n,res; while(cin>>n&&n!=0){ for(int i=1;i<=n;i++) res=(res+3)%i; cout<<res+1<<endl;; } return 0; }
Double click to view unformatted code.