// ----------------------------------------------------------- 
// FUNCTION Fibonacci Recursive Function  : (fibRecur)                          
//    Uses recursion to find the fibonacci number of the number given
// PARAMETER USAGE :                                           
//    cur: the current number to find the fib number with 
// FUNCTION CALLED :                                           
//    fibRecur: Recursively used 
// ----------------------------------------------------------- 
long int fibRecur( long int cur ) { 
    if( cur == 0 ) 
        return 0; 
    if( cur <= 2 ) 
        return 1; 
    return fibRecur( cur - 1 ) + fibRecur( cur - 2 );
}
// ----------------------------------------------------------- 
// FUNCTION Fibonacci number : (fibonacci)                          
//     computes the n-th Fibonacci number fn using recursion                            
// PARAMETER USAGE :                                           
//    n : What number fibonacci will go up to and find                
// FUNCTION CALLED :                                           
//    fibRecur: the recursive method to find the fib number 
// ----------------------------------------------------------- 
int fibonacci( long int *n ) {
    char buffer[256];

    sprintf( buffer, "      Fibonacci Process Started\n" );
    write( 1, buffer, strlen( buffer ) );    
    sprintf( buffer, "      Input Number %li\n", *n );
    write( 1, buffer, strlen( buffer ) );    

    sprintf( buffer, "      Fibonacci Number f(%li) is %li\n", *n, fibRecur( *n ) );
    write( 1, buffer, strlen( buffer ) );    
    sprintf( buffer, "      Fibonacci Process Exits\n" );
    write( 1, buffer, strlen( buffer ) );    
}
int fibRecur(int n) {
  if (n == 1 || n == 2) {return 1;}
  return fibRecur(n-1) + fibRecur(n-2);
}