Using python, please explain.
The factorial of an integer N is the product of the integers between 1 and N, inclusive. Write a while loop that computes the factorial of a given integer N.
# Reading input number from user N = int(input("Enter value for N: ")) # Initializing i to 1 # During the while loop value of i starts from i to N i = 1 # Initializing fact to 1 # The factorial is the product of value of i fact = 1 # Looping from 1 to N while(i<=N): # multiplying fact with value of i fact = fact * i # incrementing the value of i i=i+1 # Printing the calculated factorial print(fact)
Get Answers For Free
Most questions answered within 1 hours.