--Originally published at マルコ
What to Do
Create a program that asks the user for a non-negative integer (let’s call that number n) and display for them the value of n! (n factorial).
After showing them the answer, ask them if they would like to try another number (with a simple y/n response) and either ask again (for y) or quit the program and wish them a nice day (if they answered n).
Details
For the Python group, resist the urge to call math.factorial(n). Yes that would solve the problem but what would we do if there was no math.factorial() and we had no internet to find someone’s solution?
There are two basic approaches: a loop with an accumulator of the multiplication and a recursive solution. Choose one and implement that. Once that is done, try the other way.
If you used a while loop for the solution with a loop, try structuring this with a for loop (or vice-versa).
Featured image: