Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create Python Program for factorial of a number #1132

Open
wants to merge 1 commit into
base: master
from

Conversation

@Bhavesh0987
Copy link

@Bhavesh0987 Bhavesh0987 commented Oct 15, 2020

Recursive:

Python 3 program to find

factorial of given number

def factorial(n):

# single line to find factorial 
return 1 if (n==1 or n==0) else n * factorial(n - 1);  

Driver Code

num = 5;
print("Factorial of",num,"is",
factorial(num))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

1 participant
You can’t perform that action at this time.