#include <cmath>
using namespace std;
using namespace std;
double p10 (int N)
{
double s = 1, pm = -1, k = 1;
for (int i = 1; i <= N; i++)
{
k = k * i;
s = s + pm / k;
pm *= -1;
}
return (s);
}
{
double s = 1, pm = -1, k = 1;
for (int i = 1; i <= N; i++)
{
k = k * i;
s = s + pm / k;
pm *= -1;
}
return (s);
}
int main ()
{
int n;
cout << "N=";
cin >> n;
cout << " s=" << p10 (n) << "\n1./e=" << 1. / exp (1.) << endl;
}
{
int n;
cout << "N=";
cin >> n;
cout << " s=" << p10 (n) << "\n1./e=" << 1. / exp (1.) << endl;
}
No comments:
Post a Comment