Algorithm Odd-Sum-101-to-2013):
1. begin
2. SumSoFar <--0;
3. k <-- 101;
4. while (k <= 2013) do
5. SumSoFar <-- SumSoFar + k;
6. k <-- k + 2; // increment by 2
7. EndWhile
8. Even-Sum <-- SumSoFar;
9. end; |
|
|
Algorithm Odd-Sum-101-to-2013): (with repeat)
1. begin
2. SumSoFar <--0;
3. k <-- 101;
4. Repeat if (k <= 2013)
5. SumSoFar <-- SumSoFar + k;
6. k <-- k + 2; // increment by 2
7. End-Repeat
8. Even-Sum <-- SumSoFar;
9. end; |
|