MATLAB Use a while loop to determine how many terms in the s
MATLAB
Use a while loop to determine how many terms in the series2k, k = 1, 2, 3, . . . , are required for the sum of the terms to exceed 2000. What is the sum for this number of terms?
k= 10, sum=?
Solution
Solution :
We can write a script for this as
sum = 0;
k = 0;
 while sum <= 2000
 k = k + 1;
 sum = sum + 2^k;
 end
 k
 sum
And thus the sum = 2046

