#include<iostream>
using namespace std;
main()
{
int n;
cout << "Nhap n: ";
cin >> n;
if(n<0)
cout << "Moi nhap lai!!!";
else
{
int i=1, s=1;
while(i<2*n+1)
{
i=i+2;
s=s*i;
}
cout << "Tich la: " << s;
}
system("pause");
}
Nếu thêm dấu bằng lại sai
#include<iostream>
using namespace std;
main()
{
int n;
cout << "Nhap n: ";
cin >> n;
if(n<0)
cout << "Moi nhap lai!!!";
else
{
int i=1, s=1;
while(i<=2*n+1)
{
i=i+2;
s=s*i;
}
cout << "Tich la: " << s;
}
system("pause");
}