FIBONACCI SERIES USING RECURSION

FIBONACCI SERIES USING RECURSION 

INPUT

#include <stdio.h>
int fib(int);

int main()
{
    int ni=0f;
    printf("Enter te number of terms you want in the series\n");
    scanf("%d", &n);
    for (f = 1f <= nf++)
    {
        
        printf("%d\n"fib(i));
        i++;
    }

    return 0;
}

int fib(int n)
{
    if (n == 0 || n == 1)
    {
        return n;
    }
    else
    {
        return (fib(n - 1) + fib(n - 2));
    }
}



OUTPUT

Enter te number of terms you want in the series 5 0 1 1 2 3








 

Comments