Psst.. new poll here.
Psst.. new forums here.
Microsoft is blocking us again (TY IP Reputation!) so just use oauth login instead. :)
Paste
Pasted as C++ by thuan ( 5 years ago )
#include<iostream>
#include <iomanip>
using namespace std;
void Nhapso(int& n)
{
do
{
cout << "\nNhap n:";
cin >> n;
if ((n <= 10 || n >= 100) && (n % 2 == 0))
{
cout << "\nNhap lai!";
}
} while ((n <= 10 || n >= 100) || (n % 2 == 0));
}
int Giaithua(int n)
{
int giaithua = 1;
for (int i = 1; i <= n; i++)
{
giaithua *= i;
}
return giaithua;
}
float TinhF(int n)
{
float tong = 0;
for (int i = 1; i <= n; i++)
{
int phu = Giaithua(i);
tong += (float)(1 + phu) / (i + n);
}
return tong;
}
int main()
{
int n;
Nhapso(n);
float f = TinhF(n);
cout <<fixed <<setprecision(2)<<f;
cout << endl;
system("pause");
return 0;
}
Revise this Paste