how to find factorial of a number?

0 votes
May 4, 2018 in Python by ana1504.k
• 6,110 points
19 views

1 answer to this question.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
0 votes

You can find factorial by many ways. Either you use "math" module or write a complete function. For example: Calcuating the factorial of number 5

import math
print(math.factorial(5))

OR 

def factorial(n):

    if n == 0:

        return 1

    else:

        return n * factorial(n-1)

factorial(5)    

Output - 120

answered May 4, 2018 by aayushi
• 750 points

Related Questions In Python

–1 vote
2 answers

How to find the size of a string in Python?

following way to find length of string  x ...READ MORE

answered Mar 29 in Python by rajesh
• 1,210 points
40 views
0 votes
1 answer
0 votes
1 answer
0 votes
1 answer

how can i count the items in a list?

suppose you have a list a = [0,1,2,3,4,5,6,7,8,9,10] now ...READ MORE

answered May 2 in Python by Mohammad
• 1,400 points
23 views
+4 votes
6 answers
0 votes
2 answers

How to calculate square root of a number in python?

calculate square root in python >>> import math ...READ MORE

answered Apr 2 in Python by anonymous
100 views
0 votes
1 answer

How to add a new line in Python?

You can use '\n' for a next ...READ MORE

answered May 2, 2018 in Python by aayushi
• 750 points
22 views

© 2018 Brain4ce Education Solutions Pvt. Ltd. All rights Reserved.
"PMP®","PMI®", "PMI-ACP®" and "PMBOK®" are registered marks of the Project Management Institute, Inc. MongoDB®, Mongo and the leaf logo are the registered trademarks of MongoDB, Inc.