/*…Hey guy’s this is a program to find out the Fibonacci series with a twist..*/
#include <stdio.h>
long fibonacci( long ); /*..Function Prototyping..*/
long fibonacci( long ); /*..Function Prototyping..*/
/*…MAin Function Start’s…*/
int main()
{
long result, number;
printf( “Enter an integer: ” );
scanf( “%ld”, &number );
result = fibonacci( number );
printf( “Fibonacci( %ld ) = %ld\n”, number, result );
return 0;
}
int main()
{
long result, number;
printf( “Enter an integer: ” );
scanf( “%ld”, &number );
result = fibonacci( number );
printf( “Fibonacci( %ld ) = %ld\n”, number, result );
return 0;
}
/*…Main Function End’s..*/
/* Recursive definition of function fibonacci */
long fibonacci( long n )
{
if ( n == 0 || n == 1 )
return n;
else
return fibonacci( n – 1 ) + fibonacci( n – 2 );
}
/* Recursive definition of function fibonacci */
long fibonacci( long n )
{
if ( n == 0 || n == 1 )
return n;
else
return fibonacci( n – 1 ) + fibonacci( n – 2 );
}
The Output Is
No comments:
Post a Comment