Traditional Culture Encyclopedia - Photography major - C language: rabbit reproduction problem

C language: rabbit reproduction problem

The logarithm of rabbit is Fibonacci sequence.

# include & ltstdio.h & gt

Long f (long n)

{

If (n<3) returns1;

Otherwise, it returns f (n-2)+f (n-1);

}

void main()

{

Printf ("A year later, there were %ld rabbits. \n ",f( 12));

getch();

}

-

1 1 2 3 5 8 13 2 1 34 55 89 ...