For this assignment we needed to make a factorial calculator. The factorial of a number is the multiplication of all numbers that are lesser than that number until 0. For example the factorial of 4 is equal 4x3x2x1=24
This program required loops as we couldnt use the default python function from the math module.
-So first I used while loop so the user can use the program as many times he like.
while (str (res) != “n”):
print (“This program is a factorial calculator”)
n= int (input (“Please give me a positive integer number: “))
-Then I implemented a for loop in order to calculate the factorial of any given number.
for n in range (1,n+1):
print(“The factorial of the given number is: “,num)
print (“y= yes, n= no”)
res=str(input(“You wish to calculate another factorial of a number? “))
-And finally I used an If so my loop could work as I wanted.
print(“Have a nice day!”)
The final code:
Btw, I´m not sure if I completely understand how indentation works on python and on my Text editor.