Created
April 26, 2023 05:51
-
-
Save modos/022009f31b0d1c3fbc0484097490150f to your computer and use it in GitHub Desktop.
دنباله بازگشتی
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include<bits/stdc++.h> | |
using namespace std; | |
int f(int x) | |
{ | |
if(x == 0) return 5; | |
int tmp = f(x-1); // calculating f_{x-1} | |
if(x % 2 == 0) return tmp - 21; | |
else return tmp * tmp; | |
} | |
int main(){ | |
int n; | |
cin >> n; // input | |
cout << f(n) << endl; // calling f to calculate f_n | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment