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

A series of whole numbers in which each number is the sum of the two preceding n

ID: 3548294 • Letter: A

Question

A series of whole numbers in which each number is the sum of the two preceding numbers.

Beginning with 0 and 1, called Fibonacci series. The sequence of Fibonacci numbers would

be 0,1,1, 2, 3, 5, 8, 13, 21, 34, etc. Using the formula n = n(?1) + n(?2), where the n(?1)

means "the last number before n in the series" and n(?2) refers to "the second last one

before n in the series." You can calculate Fibonacci series.

Write a program that inputs a integer n and prints n number in Fibonacci series. Here is the

sample run.

Your program: please insert n

User: 5

Your program: 3

Hint: you can use recursive function to solve the problem.

Explanation / Answer

#include<stdio.h> int Fibonacci(int); int main() { int n, i, c; i=0; printf("Enter a number "); scanf("%d",&n); printf("%d ", Fibonacci(n-1)); return 0; } int Fibonacci(int n) { if ( n == 0 ) return 0; else if ( n == 1 ) return 1; else return ( Fibonacci(n-1) + Fibonacci(n-2) ); }
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote