How python uses one line of code to calculate the factorial of any number
This article mainly shows you "python how to use a line of code to calculate the factorial of any number", the content is easy to understand, clear, hope to help you solve your doubts, the following let the editor lead you to study and learn "python how to use a line of code to calculate the factorial of any number" of this article.
One line of code calculates the factorial of any number
Python 2.x.result= (lambdak: reduce (int.__mul__,range (1dache1), 1)) (3) print (result) #-> 6Python 3.x.import functoolsresult= (lambdak: functools.reduce (int.__mul__,range (1dache1), 1)) (3) print (result) #-> 6 is all the content of the article "how python uses one line of code to calculate the factorial of any number". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!