View Code of Problem 80

#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
	{
		int res = 0;
		for (int i = 2; i <= n; i++)
			res = (res + 3) % i;
		return res;
	}
}

int main() {
	int n;
	while (cin >> n && n != 0)
		cout << func(n, 3) + 1 << endl;
	return 0;
}

Double click to view unformatted code.


Back to problem 80