Files
ARPZ_s1_pr4/alg_4_5.cpp

15 lines
231 B
C++

#include <iostream>
using namespace std;
int f(int n)
{
if (n == 1) { return 1; }
if (n % 2 == 0) { return f(n / 2); }
return f((n - 1) / 2) + f((n - 1) / 2 + 1);
}
int main()
{
int n; cin >> n;
cout << f(n);
}