how to find factorial of a number

0 votes
May 4, 2018 in Python by ana1504.k
• 7,910 points
1,425 views

1 answer to this question.

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

0 votes
1 answer

How to find exponent of a number in Python?

Yes you can do it using the ...READ MORE

answered Jul 2, 2019 in Python by Arvind
• 3,040 points
2,017 views
0 votes
0 answers

How to find the number of a list item ?

Given a list ["foo", "bar", "baz"] and ...READ MORE

Sep 11, 2023 in Python by Satyawrat
• 460 points
94 views
–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, 2019 in Python by rajesh
• 1,270 points
1,532 views
–1 vote
2 answers
0 votes
2 answers
+1 vote
2 answers

how can i count the items in a list?

Syntax :            list. count(value) Code: colors = ['red', 'green', ...READ MORE

answered Jul 7, 2019 in Python by Neha
• 330 points

edited Jul 8, 2019 by Kalgi 4,007 views
0 votes
1 answer
+5 votes
6 answers

Lowercase in Python

You can simply the built-in function in ...READ MORE

answered Apr 11, 2018 in Python by hemant
• 5,790 points
3,386 views
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, 2019 in Python by anonymous
5,281 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
994 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP