Skip to content

Latest commit

 

History

History
41 lines (34 loc) · 818 Bytes

explaination.md

File metadata and controls

41 lines (34 loc) · 818 Bytes

Question [9]

WAP to display Fibonacci Series using Recursion

Code

#include <stdio.h>
int fibonacci(int n)
{
    if (n <= 1)
        return n;
    return fibonacci(n - 1) + fibonacci(n - 2);
}
int main()
{
    int n, a = 0, b = 1, tmp;
    printf("Enter N: ");
    scanf("%d", &n);
    for (int i = 0; i < n; i++)
    {
        printf("%d ", fibonacci(i));
    }
    printf("\n");
    return 0;
}

Output

Output

Code

Code