Computer Science: An Overview: Global Edition (12th Edition)

Published by Pearson Higher Education
ISBN 10: 1292061162
ISBN 13: 978-1-29206-116-0

Chapter 5 - Algorithms - Section 5.6 - Efficiency and Correctness - Questions & Exercises - Page 263: 7

Answer

Each time the test for termination is conducted, the statement “Sum + 1 + 2 + ... + K and K less than or equal to N” is true.

Work Step by Step

Each time the test for termination is conducted, the statement “Sum + 1 + 2 + ... + K and K less than or equal to N” is true. Combining this with the termination condition “K greater than or equal to N” produces the desired conclusion “Sum = 1 + 2 + ... + N.” Because K is initialized at zero and incremented by one each time through the loop, its value must ultimately reach that of N.
Update this answer!

You can help us out by revising, improving and updating this answer.

Update this answer

After you claim an answer you’ll have 24 hours to send in a draft. An editor will review the submission and either publish your submission or provide feedback.