Recursive C program to print Fibonacci series

Below is an example recursive C program to return Fibonacci series for a given number –

int fibonacci (int x){
         if(n < 0){
              printf("Invalid input");
              exit(1);
         }
         else{
             return ((n==1 || n==1)? n : fib(n-2) + fib(n-1));
         }
}

Add a Comment

Your email address will not be published. Required fields are marked *