Forked from epoll-reactor/gist:efc56996a08661f9feeb70ba28e74b07
Last active
January 26, 2020 10:13
-
-
Save Konard/fc700b03f64b5c92c6fb56e53d6f8ca8 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<iostream> | |
using namespace std; | |
int foo(int n) | |
{ | |
if (n == 0) | |
{ | |
return 3; | |
} | |
if (n == 1) | |
{ | |
return 2; | |
} | |
else | |
{ | |
return foo(n-1) * foo(n-2) - n; | |
} | |
} | |
int main() | |
{ | |
int n = 0, n1 = 0, n2 = 0, res = 0; | |
cout << "cin n: "; | |
cin >> n; | |
if (n == 0) | |
{ | |
n1 = 3; | |
} | |
if (n == 1) | |
{ | |
n2 = 2; | |
} | |
int i = 0; | |
while (n > 1) | |
{ | |
if (i >= n) | |
{ | |
break; | |
} | |
res = n1 * n2 - i; | |
n1 = n2; | |
n2 = res; | |
i++; | |
} | |
cout << res; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment