S=1 + 1/2^2 + 1/3^2 + ... + 1/n^2
Để bình luận, bạn cần đăng nhập bằng tài khoản Howkteam.
phân tích ra mà làm chớ bạn.
#include <iostream> #include <cmath>
using namespace std;
int main() { int n; double sum = 0.0;
cout << "Enter the value of n: "; cin >> n;
// Calculate the sum of the series for (int i = 1; i <= n; i++) { sum += 1.0 / pow(i, 2); }
// Display the result cout << "The sum of the series is: " << sum << endl;
return 0; }
Để sử dụng tính năng này, Bạn cần đăng nhập bằng tài khoản Howkteam.
Để xem được nội dung và giúp Kteam duy trì hoạt động. Bạn vui lòng tắt Adblock trên website howkteam.vn nhé!
phân tích ra mà làm chớ bạn.
#include <iostream>
#include <cmath>
using namespace std;
int main() {
int n;
double sum = 0.0;
cout << "Enter the value of n: ";
cin >> n;
// Calculate the sum of the series
for (int i = 1; i <= n; i++) {
sum += 1.0 / pow(i, 2);
}
// Display the result
cout << "The sum of the series is: " << sum << endl;
return 0;
}