fork download
  1. #include <iostream>
  2. #include <string>
  3. using namespace std;
  4.  
  5. int f(int x, int y)
  6. {
  7. if (x <= 0) {
  8. return y;
  9. }
  10. return f(x - 1, y + 1) - f(x / 2, y * 2);
  11. }
  12.  
  13. int main()
  14. {
  15. cout << "answer: " << f(4, -1);
  16. return 0;
  17. }
Success #stdin #stdout 0s 4380KB
stdin
Standard input is empty
stdout
answer: 2