Website Summary Files Commits Branches @commit @diff @stats
path: root / Week13 / Exercise08.cpp
blob: 850bd123795f73edcdf5e6c2fc5f241284b508ea (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#include <iostream>

unsigned fib(unsigned n) {
	if (n <= 1)
		return n;
	else
		return fib(n - 1) + fib(n - 2);
}

void intertwinedFib(unsigned i, unsigned max) {
	if (i > max) {
		std::cout << std::endl;
	}
	else {
		if (i > 0)
			std::cout << ' ';
		std::cout << fib(i) << ' ' << fib(max - i);
		intertwinedFib(i + 1, max);
	}
}

int main() {
	unsigned n;
	std::cin >> n;

	intertwinedFib(0, n);

	return 0;
}