#include<iostream> #include<string> #include<algorithm> #include<cmath> #include<iomanip> using namespace std; int func(int n, int m) { if (n == 1) return 0; else return (func(n - 1, m) + m) % n; } int main() { int n; while (cin >> n && n != 0) cout << func(n, 3) + 1 << endl; return 0; } |
Double click to view unformatted code.