Problem 46873. Sum of terms in a series 2 (★★★)
Given x and n, compute the following sum:
Thus, if x = 0.1 and n = 5, then the sum is (up to n = 5 terms)
0.1+2*(0.01)+3*(0.001)+4*(0.0001)+5*(0.00001)
= 0.12345
Avoid using for/while loops.
Solution Stats
Problem Comments
-
2 Comments
Rafael S.T. Vieira
on 18 Oct 2020
Please, do not use isqual with floats, instead use abs(x1-x2) < 1e-10 for instance. A number like 0.1 is infinite and periodic in base 2.
goc3
on 27 Oct 2020
The test suite is updated to use a tolerance check.
Solution Comments
Show commentsProblem Recent Solvers36
Suggested Problems
-
Flip the main diagonal of a matrix
838 Solvers
-
Find out missing number from a vector of 9 elements
302 Solvers
-
292 Solvers
-
ベクトル [1 2 3 4 5 6 7 8 9 10] の作成
566 Solvers
-
Matlab Basics II - Max & Index of Max
255 Solvers
More from this Author52
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!