Hello,

I'm trying to calculate factorials with my program, but it is only working for the first few numbers. It compiles fine, so I can't find the problem. Help please! Keep it simple, I am very new to C++ and programming in general.

Here is my code:

```
#include <iostream>
#include <cmath>
using namespace std;
int factorial(int);
int factorial(int n)
{
int i=0, fact=1;
if(n<=1)
{
return(1);
}
else
{
for (i=1; i<=n; i++)
{
fact=fact*i;
}
return(fact);
}
}
int main()
{
int i, z, q;
int n=10;
for (i=0; i<=n; i++)
{
q=((2*i)+1);
z=factorial(q);
cout<<z <<endl;
}
system("PAUSE");
return 0;
}
```

It works for i=0 to i=6, but after that the values are incorrect.