# Fibonacci series program in C using Recursion

In this tutorial, we’ll explore how to utilise recursion to build the Fibonacci sequence in C language.

## What does the term "Fibonacci Series" mean?

The following number in a Fibonacci number series is essentially the summation of the previous two values (preceding numbers). In every series, the first two integers are still 0 and 1. Thus, the sequence is as follows: 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, so on.

### How to write the Fibonacci Sequence in C?

Two of the main approaches that can be used to write this series in C language:

• Using Recursion (Only this approach is discussed in this tutorial)
• Without Recursion

### Fibonacci Series using Recursion:

Let's look at a recursive Program for the Fibonacci series in C Language

Code:

C Program to write Fibonacci Series

``````#include<stdio.h>

void printFibonacciseries(int p)
{

static int p1=0, p2=1, p3; //considering variables

if( p > 0 ) //if condition is true it will execute
{
//logic

p3 = p1 + p2;

p1 = p2;

p2 = p3;

printf("%d ", p3); //printing value of the series

printFibonacciseries( p - 1) ; //user-defined function

}

}

int main()
{

int p; //considering variable

printf("Enter any number to create Fibonacci Series: "); //asks user for a input

scanf("%d", & p); //storing value in variable p

printf("The Fibonacci Series should be: "); //printing statement

printf("%d %d ",0,1); //printing 0 and 1 as these are common for all fibonacci series

printFibonacciseries( p - 2 ); //using p-2 as we have already printed two numbers here

return 0;

}
``````

Output: (If user puts 11 as input)

``````Enter any number to create Fibonacci Series: 11
The Fibonacci Series should be: 0 1 1 2 3 5 8 13 21 34 5``````

Output: (If user puts 9 as input)

``````Enter any number to create Fibonacci Series: 9
The Fibonacci Series should be: 0 1 1 2 3 5 8 13 21``````
{"ft_lang_label":"__label__en","ft_lang_prob":0.78815496,"math_prob":0.8383901,"size":1818,"snap":"2022-27-2022-33","text_gpt3_token_len":528,"char_repetition_ratio":0.17640573,"word_repetition_ratio":0.099378884,"special_character_ratio":0.29592958,"punctuation_ratio":0.14054054,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.99955446,"pos_list":[0],"im_url_duplicate_count":[null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2022-08-08T13:08:08Z\",\"WARC-Record-ID\":\"<urn:uuid:85e27ea1-c420-4e92-a6fe-9b3335133b69>\",\"Content-Length\":\"52453\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:7800ef04-98c6-4a3f-b11a-da2646943f3c>\",\"WARC-Concurrent-To\":\"<urn:uuid:64807479-dc03-4762-9fb6-f2f65edfb717>\",\"WARC-IP-Address\":\"172.67.165.79\",\"WARC-Target-URI\":\"https://www.tutorialandexample.com/fibonacci-series-program-in-c-using-recursion\",\"WARC-Payload-Digest\":\"sha1:XDIERUL6CNSTPPTDHPQ5RCDOIUQ5EV4X\",\"WARC-Block-Digest\":\"sha1:NLRHTRU24AKUJOSCLMGQ2W46SBXXFXJ2\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2022/CC-MAIN-2022-33/CC-MAIN-2022-33_segments_1659882570827.41_warc_CC-MAIN-20220808122331-20220808152331-00635.warc.gz\"}"}