Algorithm 4

Carry out the following instructions.

  1. Draw a box, label the box A, write the number 1 in box A
  2. Draw a box, label the box S write the number 999 in box S
  3. Draw a line that values may be written on, label the line Output
  4. If the number in box A is less than or equal to 5 then do the next instruction, otherwise do instruction 9
  5. Replace the number in box S with the number in box A squared
  6. Write the number in box S on the line labeled Output
  7. Replace the number in box A with the number that is one more than the number currently in box A
  8. Go back and do instruction 4 again
  9. You are done

Describe the sequence of numbers on the Output line.

How did the number 999 put initially in box S in instruction 2 affect the result?

Note the second box, S, was used to "remember" the square of the the current value in box A.