Untitled

mail@pastecode.io avatar
unknown
c_cpp
2 years ago
374 B
2
Indexable
Never
#include <iostream>

long double  f(long double a) {
	long double factorial = 1;
	while (a > 1) {
		factorial *= a;
		a--;
	}
	return factorial;
}

int main() {
	long double  n = 0;
	std::cin >> n;

	long double s = 0;
	long double nf = f(n);
	for (int k = 2; k <= n; k++) {
		s += nf/f(n-k);
	}

	std::cout.precision(0);
	std::cout << std::fixed << s << "\n";
	return 0;
}