10843 - Fibonacci number   

Description

The  Fibonacci sequence are the numbers in the following intergur sequence:

 

0,\;1,\;1,\;2,\;3,\;5,\;8,\;13,\;21,\;34,\;55,\;89,\;144,\; \ldots\; In mathematical terms, the sequence Fn of Fibonacci numbers is defined by the first two numbers in the Fibonacci sequence are  0 and 1, and each subsequent number is the sum of the previous two.

F_n = F_{n-1} + F_{n-2},\!\,       

F_0 = 0,\; F_1 = 1.

You should enter a index of Fibonacci sequence ,and then output a  Fibonacci numbers of this index 

Ex:  input 0 outout 0

       input 1 outout 1

       input 2 outout 1

       input 3 outout 2  etc..

 

Note that

1.      This problem involves three files.

  • function.h: Function definition of Fibr.
  • function.c: Function describe of Fibr.
  • main.c: A driver program to test your implementation.

You will be provided with main.c and function.h, and asked to implement function.c.

2.     For OJ submission:

       Step 1. Submit only your function.cpp into the submission block. (Please choose C compiler) 

       Step 2. Check the results and debug your program if necessary.

function.h

#ifndef FUNCTION_H

#define FUNCTION_H

int Fibr(int index);

#endif

main.c

#include <stdio.h>
#include "function.h"
int main(void)
{
    int index,n,i;
    scanf("%d",&index);
    n=Fibr(index);
    printf("index = %d,  Fibonacci numbers = %d",index,n);

    return 0;
}

Input

The decimal number index that indicates the number of  Fibonacci sequence.

0 ≤ index ≤ 35

Output

You should output of this index is what number.

Sample Input  Download

Sample Output  Download

Partial Judge Code

10843.c

Partial Judge Header

10843.h

Tags




Discuss