Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

/******************************************************************************

ID: 3608609 • Letter: #

Question

/******************************************************************************
genFibonacci() computes the first N Fibonacci numbers and storesthem, in
sequence in the array F.
Pre: F[] is an array of dimension >= N.
N has been initialized.
Post: The first N cells of F[] contain the first N Fibonaccinumbers.
If N exceeds the dimension of F[] the behavior is undefined (butalmost
certainly not enjoyable).
******************************************************************************/
void genFibonacci(unsigned int F[], unsigned int N);
The sequence of Fibonacci numbers are defined by the followingrecurrence relation:
F(0)=F (1) =1
F(N )=F(N- 2)+F (N- 1) for N > 1

Explanation / Answer

void genFibonacci(unsigned int F[], unsigned int N) { if(N==0) /*If they don't want any fibonacci numbers let'sgive them what they ask for*/    {    return;    } F[0]=1; /*By definition we know the first fibonacci number is1*/ if(N==1) /*If they just wanted that single fibonacci number thenthey can have it*/    {    return;    } F[1]=1; /*By definition the second fibonacci number is also 1*/ if(N==2)    {    return;    } int i; for(i = 2; i