fsdaf

dsaf
mail@pastecode.io avatar
unknown
plain_text
2 months ago
411 B
1
Indexable
Never
#include <stdio.h>
int fib(int n) {
    if (n <= 1) {
        return n;
    }

    return fib(n - 2) + fib(n - 1);
}
int main() {
    int n;
    printf ("Enter the Nth No.: ");
    scanf("%d",&n);

    printf("Nth Fibonacci number is: %d\n\n",fib(n));

    printf("Full Fibonacci series is:\n");

    for (int i = 0; i <= n; ++i) {

        printf("%d  ",fib(i));
    }

    return 0;
}
Leave a Comment