View Code of Problem 610

#include <stdio.h>

int fun(int n) {
	if (n == 1) {
		return 1;
	}
	return 3 * fun(n - 1) - 1;
}

int main() {
	int n;
	while (scanf("%d", &n) != EOF) {
		int res = fun(n);
		printf("%d\n", res);
	}
}

Double click to view unformatted code.


Back to problem 610