You are viewing a single comment's thread. Return to all comments →
//Complete the following function.
int find_nth_term(int n, int a, int b, int c) { //Write your code here. int ret = 0; int d = 0;
if(n == 1) { ret = a; } else if(n == 2) { ret = b; } else if(n == 3) { ret = c; }else{ d = c + b + a; ret = find_nth_term(n - 1, b, c, d); } return ret;
}
int main() { int n, a, b, c;
scanf("%d %d %d %d", &n, &a, &b, &c); int ans = find_nth_term(n, a, b, c); printf("%d", ans); return 0;
Seems like cookies are disabled on this browser, please enable them to open this website
Calculate the Nth term
You are viewing a single comment's thread. Return to all comments →
include
include
include
include
//Complete the following function.
int find_nth_term(int n, int a, int b, int c) { //Write your code here. int ret = 0; int d = 0;
}
int main() { int n, a, b, c;
}