而在 C++ 中计算地理矩阵序列

while in c++ to count geomatric series

本文关键字:C++ 计算 而在      更新时间:2023-10-16

如何使用 while 来计算这个?

1/(1 × 1) − 1/(2 × 2) + 1/(3 × 3) − 1/(4 ×

4) + 1/(5 × 5) − ⋯这条线走向无穷大,所以我们无法计算它,然后我们给出限制,忽略 10e-6 以下的数字

我不会为你做功课。我将为您指出解决方案的方向。

const double epsilon = 1e-6;
double term = 1.0, result = 0.0, x;
x = 1.0 / (term * term);
while (x > epsilon) {
  // rest of code here
}