#include <iostream>
#include <vector>
#include <cmath>
using namespace std;
double fac(double k){
if(k == 1)
return 1;
return k * fac(k-1);
}
signed main(){
int n;
cin >> n;
double sum = 0;
double k = 1;
for(k; k <= n; k++)
sum += 1/fac(pow(k,2));
cout << sum;
Дан во вложении.
#include <iostream>
#include <vector>
#include <cmath>
using namespace std;
double fac(double k){
if(k == 1)
return 1;
return k * fac(k-1);
}
signed main(){
int n;
cin >> n;
double sum = 0;
double k = 1;
for(k; k <= n; k++)
sum += 1/fac(pow(k,2));
cout << sum;
}
Дан во вложении.