- Learn C By Examples Time
- Learn C by Examples - Home
- C Examples - Simple Programs
- C Examples - Loops/Iterations
- C Examples - Patterns
- C Examples - Arrays
- C Examples - Strings
- C Examples - Mathematics
- C Examples - Linked List

- C Programming Useful Resources
- Learn C By Examples - Quick Guide
- Learn C By Examples - Resources
- Learn C By Examples - Discussion

'; var adpushup = adpushup || {}; adpushup.que = adpushup.que || []; adpushup.que.push(function() { adpushup.triggerAd(ad_id); });

Fibonacci Series generates subsequent number by adding two previous numbers. Fibonacci series starts from two numbers − F_{0} & F_{1}. The initial values of F_{0} & F_{1} can be taken 0, 1 or 1, 1 respectively.

Fibonacci series satisfies the following conditions −

F_{n}= F_{n-1}+ F_{n-2}

So a Fibonacci series can look like this −

F_{8} = 0 1 1 2 3 5 8 13

or, this −

F_{8} = 1 1 2 3 5 8 13 21

## Algorithm

Algorithm of this program is very easy −

START Step 1 → Take integer variable A, B, C Step 2 → Set A = 0, B = 0 Step 3 → DISPLAY A, B Step 4 → C = A + B Step 5 → DISPLAY C Step 6 → Set A = B, B = C Step 7 → REPEAT from 4 - 6, for n timesSTOP

## Pseudocode

procedure fibonacci : fib_num IF fib_num less than 1 DISPLAY 0 IF fib_num equals to 1 DISPLAY 1 IF fib_num equals to 2 DISPLAY 1, 1 IF fib_num greater than 2 Pre = 1, Post = 1, DISPLAY Pre, Post FOR 0 to fib_num-2 Fib = Pre + Post DISPLAY Fib Pre = Post Post = Fib END FOR END IFend procedure

## Implementation

Implementation of this algorithm is given below −

#include <stdio.h>int main() { int a, b, c, i, n; n = 4; a = b = 1; printf("%d %d ",a,b); for(i = 1; i <= n-2; i++) { c = a + b; printf("%d ", c); a = b; b = c; } return 0;}

## Output

Output of the program should be −

1 1 2 3

mathematical_programs_in_c.htm

Previous Page Print PageNext Page

Advertisements

';adpushup.triggerAd(ad_id);});

## FAQs

### How to solve Fibonacci series in C? ›

**Fibonacci Series Program In C**

- Algorithm. Algorithm of this program is very easy − START Step 1 → Take integer variable A, B, C Step 2 → Set A = 0, B = 0 Step 3 → DISPLAY A, B Step 4 → C = A + B Step 5 → DISPLAY C Step 6 → Set A = B, B = C Step 7 → REPEAT from 4 - 6, for n times STOP.
- Pseudocode. ...
- Implementation. ...
- Output.

**What is the 1 2 3 5 8 series in C? ›**

**Fibonacci Series** in C: In the fibonacci series, the next number is the sum of the preceding two numbers, such as 0, 1, 1, 2, 3, 5, 8, 13, 21, and so on. The fibonacci series' first two integers are 0 and 1. The Fibonacci Series Looks like this : 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89.............

**How to print Fibonacci series in C without using loop? ›**

Declare three variable a, b, sum as 0, 1, and 0 respectively. Call recursively fib() function with first term, second term and the current sum of the Fibonacci series. After main function call fib() function, the fib() function call him self until the N numbers of Fibonacci Series are calculated.

**How to print Fibonacci series in C using array? ›**

**Fibonacci series using Array**

- fibo[0]=0; fibo[1]=1;
- for (i=2;i<=9;i++) {
- fibo[i]=fibo[i-1]+fibo[i-2]; }
- for (i=0;i<=9;i++) {
- printf("%d",fibo[i]); }
- return 0; }

**What is a perfect number in C? ›**

Introduction. A perfect number program in c is **a number, whose sum is equal to its positive divisor but excludes the number itself**. For instance, the number 6 is divisible by 1, 2, and 3 completely. The number also divides itself but for a perfect number, the number divisible by itself is excluded.

**What is the pattern of 1 1 2 3 5 8? ›**

**The Fibonacci sequence** is a famous group of numbers beginning with 0 and 1 in which each number is the sum of the two before it. It begins 0, 1, 1, 2, 3, 5, 8, 13, 21 and continues infinitely.

**What are 4 examples of Fibonacci sequence? ›**

Understanding the Fibonacci Sequence

Each number is equal to the sum of the preceding two numbers. For example, **0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377**.

**How do you find the nth number in a Fibonacci sequence? ›**

We have only defined the nth Fibonacci number in terms of the two before it: the n-th Fibonacci number is **the sum of the (n-1)th and the (n-2)th**.

**What is the 7th term in the series 1 1 2 3 5 8? ›**

The Fibonacci sequence is as follows: **0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987, 1597, 2584, 4181, 6765, 10946**,….

**How do you find the nth term of a series 1 1 2 3 5 8? ›**

The Fibonacci sequence is the series of numbers: 0, 1, 1, 2, 3, 5, 8, 13, 21, 34... In this series, the next number is found by adding the two numbers before it. Hence, the next term in the series is **8 + 13 = 21**.

### What is the series of 1 4 27 256 in C? ›

Detailed Solution

Hence, '**3125**' is the correct answer.

**How do you solve a Fibonacci sequence without recursion? ›**

The logic of calculating nth Fibonacci number is implemented in this method and it does that without using recursion. It uses a simple for loop to iterate until the nth number and calculate Fibonacci number using the following formula : **f(n) = f(n-1) + f(n-2);**

**What is Fibonacci series in C using while loop? ›**

Enter a positive integer: 100 Fibonacci Series: 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, In this program, we have used a while loop to **print all the Fibonacci numbers up to n** . If n is not part of the Fibonacci sequence, we print the sequence up to the number that is closest to (and lesser than) n .

**What is Fibonacci series using recursion in C? ›**

Fibonacci Series Using Recursion in C refers to **a number series**. The Fibonacci series is created by adding the preceding two numbers ahead in the series. Zero and one are the first two numbers in a Fibonacci series.

**How to print Fibonacci series in reverse order in C? ›**

**Print Fibonacci Series in reverse order**

- Declare an array of size n.
- Initialize a[0] and a[1] to 0 and 1 respectively.
- Run a loop from 2 to n-1 and store. sum of a[i-2] and a[i-1] in a[i].
- Print the array in the reverse order.