0

Hi

while doing my homeworks, i stucked here ..

Writting a program to calculate the factorial of positive integer .

here is my code:

```
int main ()
{
int x,factorial;
cout<<"Enter an integer to calculate its factorial: ";
cin>>x;
if (x==1 && x==0)
{
cout<<"\nThe facotrial is: 1";
}
else
{
if (x<0)
{
cout<<"\nMath Error";
}
if (x>1)
{
cout<<"\nCalculating...";
factorial = x;
while (x>1)
{
factorial = factorial * ( factorial - 1 );
x--;
}
}
}
cout<<"\nThe facotrial is: "<<factorial<<endl;
return 0;
}
```

I know there is an arithmetic error ..

Thanks !

*Edited 7 Years Ago by Frap*: n/a