+ 1

How can calculate factorial in python

25th Aug 2019, 12:15 PM
Devansh Raniwala
Devansh Raniwala - avatar
3 Answers
+ 5
calculating factorial is not language specific, you can make logic which will be valid mostly in all languages(can be loop, recursion etc). Python have pre-defined function for calculating factorial: import math print(math.factorial(n)) #might its not available in other languages which I know
25th Aug 2019, 2:05 PM
Gaurav Agrawal
Gaurav Agrawal - avatar
+ 3
You can very easily make factorial using for loops. #Factorial of 6! x = 1 y = 6 for i in range(2, y + 1): x *= i print(x) #Output: 720
25th Aug 2019, 12:27 PM
Seb TheS
Seb TheS - avatar