Matching a post-test flowchart loop to pseudocode

A student draws the flowchart below for a routine that adds up squares of whole numbers.


A flowchart that inputs n, sets sum to 0 and k to 1, adds k times k to sum, increases k by 1, then tests whether k is greater than n, looping back on No and outputting sum on Yes.


Which pseudocode produces the same output as the flowchart for every integer input nn, including n≤0n \le 0?

Choose an answer

Create a free account to get started

Unlock full course notes by signing up

  • Video lessons taught by top educators
  • Practice questions with guided solutions
  • Written review notes for reference
  • Expert answers anytime from course tutors