You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
23 lines
385 B
23 lines
385 B
#include <iostream>
|
|
|
|
using namespace std;
|
|
|
|
int func(int x) {
|
|
if (x <= 3)
|
|
return x * 2 - 1;
|
|
else if (x >= 6)
|
|
return func(x - 3) - 2;
|
|
else
|
|
return func(x + 1) + x;
|
|
}
|
|
|
|
int main() {
|
|
cout << func(14);
|
|
// f(14)=f(11)-2;
|
|
// f(11)=f(8)-2
|
|
// f(8)=f(5)-2
|
|
// f(5)=f(6)+5
|
|
// f(6)=f(3)-2
|
|
// f(3)=5
|
|
return 0;
|
|
} |