program to print the factorial of first five elements of the fibonacci series



# include
# include


long fibonacci(long);
long factorial(long);

int main( )
{
clrscr( );

cout<<"\n The first five elements of the fibonacci series are : ";

for(int count_1=0;count_1<5;count_1++)
cout<
cout<<"\n\n The factorial first five elements of the fibonacci series are : ";

for(int count_2=0;count_2<5;count_2++)
cout<
getch( );
return 0;
}

/*************************************************************************//*************************************************************************///------------------------ Function Definitions -----------------------///*************************************************************************//*************************************************************************//*************************************************************************///-------------------------- fibonacci(long) --------------------------///*************************************************************************/long fibonacci(long number)
{
if(number==0 || number==1)
return number;

elsereturn fibonacci(number-1)+fibonacci(number-2);
}

/*************************************************************************///-------------------------- factorial(long) --------------------------///*************************************************************************/long factorial(long number)
{
int count=1;
int factorial=1;

if(number==0)
factorial=1;

else
{
do
{
factorial=factorial*count;
count++;
}
while(count<=number);
}

return factorial;
}



No comments:

Post a Comment