Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- double factorial(int n){
- double res = 1;
- int i = 1;
- while (i <= n){
- res *= i;
- i++;
- }
- return 1.0/res;
- }
- void fill(double a[],int n){
- double sum=0;
- for (int i = 0; i < n+1; i++) {
- a[i] = factorial(i);
- sum=sum+a[i];
- }
- cout<<sum<<endl;
- }
- int main()
- {
- int n;
- cout << "Введите количество элементов : ";
- cin >> n;
- double * a = new double[n+1];
- fill(a, n);
- delete [] a;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement