Current location - Training Enrollment Network - Mathematics courses - Recursive function mathematics
Recursive function mathematics
Integer f (integer n)

{

if (n == 0 || n == 1)

Returns n;

other

Returns 2 * f (n-1)+3 * f (n-2);

}

The mathematical solution is as follows:

The characteristic equation of recursive equation is:

X 2 = 2x+3, the characteristic root of the solution is x 1=- 1, x2=3,

So f (n) = c1* (1) n+C2 * 3n, and then substitute f (0) = 1, f (1) = 1, and you get the solution.

C 1 =- 1/4 and C2 = 1/4, so f (n) =-1/4 * (1) n+1/4 * 3n.

This is the knowledge of discrete mathematics.