C language --- Fibonacci number

#include <stdio.h>
#include <string.h>
/ *:
recursive problems: 1, Fibonacci column
, also known as rabbit series, based on rabbit breeding, for example, come to this series: 1,1,2 , and 3,5,8 ... refers to the beginning of the third value, each value is the value of the first two.
* /
// August 2019 28
void Fun (shu_zu int [], int NUM)
{int I, J, K;

for (I =. 3; I <NUM; I ++)
{
shu_zu [I] = shu_zu [I- . 1] + shu_zu [I-2];
}
}
int main ()
{int ARR [100] = {1,1,2};
int valun, I;
the printf ( "enter the length of sequence:");
Scanf ( "% D", & valun);
Fun (ARR, valun);
for (I = 0; I <valun; I ++)
the printf ( "% D \ n-", ARR [I]);
return 0;
}

 

Guess you like

Origin www.cnblogs.com/qianrushi1/p/11431141.html