// First Example for the Factorial 
//********************************************************************
#include <iostream.h>

int Facto(int);
void main()
{
	int Num,res;
	while(1)
	{
		cout<<"Enter an Integer Number to calculate its Factorial or a negatif number to QUIT\n";
		cin >> Num;
		if(Num <0)
			break;
		else
		{
			res=Facto(Num);
			cout << "The Factorial is : "<<res << "\n";
		}
	}
}
int Facto(int n)
{
	if(n==0 || n==1)
	{
		return 1;
	}
	else
	{
		return (n*Facto(n-1));
	}
}


//****************************************************************
//****************************************************************
//****************************************************************
//Second Example for the serie 
//  1 + 1/2 - 1/3 + 1/4 - 1/5 + 1/6 - 1/7 + 1/8 ......


#include <iostream.h>

double Serie(double,int);
void main()
{
	int Num,Sign;
	double res;
	
	while(1)
	{
		cout << "Enter the Number for the serie or 0 to QUIT\n";
		cin >> Num;
		if(!Num)
			break;
		if(!(Num % 2))
		{
			Sign=1;
		}
		else
		{
			Sign=-1;
		}
		res=Serie((double)Num,Sign);
		cout <<" The result of the serie is : "<<res <<"\n";
	}
}
//The recursive Function
double Serie(double n,int s)
{
	if(n == 1)
		return 1;
		return (((double)s/n)) + Serie(n-1,-s);
}