Home > Back-end >  thank you
thank you

Time:06-06

High school math everyone learned sequence, one of the important concept is the general term series, can represent the sequence of each item of an expression,
Our problem today is related to general term, said, give you a sequence of general term and in the first several, hope you can find out its n items,
The general expression is as follows:
F (1)=0;
F (2)=1;
F (n)=4 * F (n - 1) - 5 * F (n - 2);
Input
Input data to the first line is a positive integer T, T<100, the following T lines, each line an integer n, 2 & lt; n<50,
The Output
T lines output, for each line in the input of n calculated in accordance with the general term F (n),

CodePudding user response:

Can begin to write ah, this is general term formula with recursion, it's easy to write
 
Int F (int n) {
If (n==1)
return 0;
Else if (n==2)
return 1;
Return 4 * F (n - 1) - 5 * F (n - 2);
}

CodePudding user response:

I hope it can help you: https://blog.csdn.net/it_xiangqiang/category_10581430.html
I hope it can help you: https://blog.csdn.net/it_xiangqiang/category_10768339.html
  • Related