_takumi

num16

Oct 8th, 2020
885
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.25 KB | None | 0 0
  1. #include <iostream>
  2. #include <vector>
  3. using namespace std;
  4.  
  5. int F(int n) {
  6.     if (n == 1) {
  7.         return 1;
  8.     }
  9.     if (!(n & 1)) {
  10.         return n + F(n - 1);
  11.     }
  12.     if (n & 1) {
  13.         return 2 * F(n - 2);
  14.     }
  15. }
  16.  
  17. int main() {
  18.     cout << F(26);
  19.     return 0;
  20. }
Advertisement
Add Comment
Please, Sign In to add comment