Write A Python Program Using A Function To Print Factorial Number Series From N To M Numbers
Hi Programmers, welcome to my blog, lets try to get python solution for write a python program using a function to print factorial number series from n to m numbers.
Title :
Python Problem : Write A Python Program Using A Function To Print Factorial Number Series From N To M NumbersDescription :
Define a factorial function to find product of factors, then ask user to enter two numbers n and m validate the numbers range, n should be less than m, and then n should be greater than or equal to zero, use for loop in range of n, m and keep finding the factorial and append to factorial list. Finally print the factorial_list., nan
Code :
def fact(x): if x == 0 or x == 1: return 1 else: product = 1 while(x > 1): product = product * x x = x - 1 return product n = int(input("Enter value of n : ")) m = int(input("Enter value of m : ")) factorial_list = [] if n <= m and n >= 0: # check for range and non zero values for temp in range(n, m+1): factorial_list += [fact(temp),] print("Factorial between range is ...") print(factorial_list) """ output : =========================================== Enter value of n : 4 Enter value of m : 9 Factorial between range is ... [24, 120, 720, 5040, 40320, 362880] """
Conclusion :
Once you are done with reading the above code, open your python editor, try to write the program by yourself. This will improve your coding skills, try changing variable names, change operators and execute it.
Thank you for reading my article about write a python program using a function to print factorial number series from n to m numbers if you have any queries about above solution, please comment down below, if you like this article share it with your friends.
0 Comments