I am having trouble interpreting how to write this fragment?
sum<--0
for i from 1 to n
sum <-- sum -1
for j from 1 to i
sum <-- sum + 2
Loading
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Michal HabalcikPosted Jan 15, 2015, 1:37 AM
int sum = 0;
int n = ???;
for (int i=1; i <= n; i++)
{
sum -= 1;
for (int j=1; j<=i; j++)
sum += 2;
}Philip HarrisPosted Jan 20, 2015, 10:33 PM