What is Factorial?
Factorial is simply the product of an integer including all positive integers below the specific integer.
For example, the factorial of 3 is 6. Its because 3 x 2 x 1 = 6.
Like wise, the factorial of 4 is 24.
In this activity, we will develop a python code that is capable to calculate the factorial of a given integer by the user.
# Ask for an input integer
# Calculate the factorial
# Print the factorial
I have mentioned the code that I developed to find the factorial.
#Using the while loop to find factoriali = 1factorial = 1num = 1num = int(input("Number: "))while i < num + 1: factorial = factorial*i i+=1print (factorial)
Oops! This image does not follow our content guidelines. To continue publishing, please remove it or upload a different image.
YOU ARE READING
Python programming for Beginners
Non-FictionThis book contains different activities that are useful to practice python as a beginner.
