Hi ,

Here is my three factorial programs:

I asked to the user a number then I created a function to display the value of the factorial.

I used three method: first of all with the recursive solution then with the loops while and for !

According to me, recursive solution was the easiest because you have to write in first the both special case with 0 and 1, then you add the formula that you know since you are younger.

With the loops I used the same formula but I reasoned in the different way for each other : With the for loop you have to know how many times you want to execute your code whereas with the while loop you have to find the good precondition.

Then, I created a common menu to ask to the user if he wants to start again or quit the program.

I used the while loop. First, I asked the number, then I called my method. Then I ask the question y/n.

My stop condition is when the user answers « no ».

Have a good day !

Capture d’écran 2015-10-16 à 22.51.47 Capture d’écran 2015-10-16 à 22.48.53 Capture d’écran 2015-10-16 à 22.45.31

CC BY 4.0 WSQ09 #TC101 by aureliemartinette is licensed under a Creative Commons Attribution 4.0 International License.