164k views
4 votes
Use a while loop to determine how many terms in the series 3k^2 are required for the sum to surpass 2000

2 Answers

4 votes
I am assuming k starts at 0. Python code (or pseudocode) would be this:
-------------------------------
S = 0
count_term = 0
k = 0
while S <= 2000: S = S + 3*k**2
count_term = count_term + 1 k = k + 1

print(count_term)
-------------------------------

It will print 14

If k should start at other number then just replace number at third line and execute it.
User Anton  Bogdanov
by
7.3k points
3 votes
Using JAVA:
int sum = 0;
int k = 1;
while(sum <= 2000) {
sum += 3*k*k;
k++;
}
System.out.println(k);

Output: 14

Which means it will take 14 terms for the series to surpass 2000


User Umeboshi
by
8.2k points