A good answer might be:

It will use a loop that counts 1, 2, 3, 4, 5 and multiplies these values together.


Flowchart of the Program

Another way to do this is to use N as the counter, and count it down until it reaches 2, so its values are: 5, 4, 3, and 2. These values are multiplied together one by one. There is no need to multiply by 1, so the loop's condition is N > 1.

The flowchart shows how the program works. First it tests if N is positive. If so, it calculates N!

This program uses somewhat trickier logic than previous programs have used. Study the flowchart until you see how it works. Don't worry about the details. The flowchart says nothing about which language the program is written in. The same flowchart could be used for any language.



QUESTION 7:

Mentally go though the chart for some values of N. Does it work correctly for N == -5, N == 0, N == 1, N == 4 ???