Home > Back-end >  Who can teach me thank @
Who can teach me thank @

Time:06-07

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:

 int fab (int n) 
{
If (n==1)
return 0;
If (n==2)
return 1;

Overall return 4 * (n - 1) - 5 * fab (n - 2);
}

May cross ~ can consider to use double or unsigned long long

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