Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 61e19a5

Browse filesBrowse files
Merge pull request seeditsolution#286 from mrlazyProgrammer/patch-1
Python Program to Find the Factorial of a Number
2 parents fc51376 + 216bfb6 commit 61e19a5
Copy full SHA for 61e19a5

File tree

Expand file treeCollapse file tree

1 file changed

+19
-0
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

1 file changed

+19
-0
lines changed
Open diff view settings
Collapse file

‎Factorial of a Number‎

Copy file name to clipboard
+19Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# Python program to find the factorial of a number provided by the user.
2+
3+
# change the value for a different result
4+
num = 7
5+
6+
# To take input from the user
7+
#num = int(input("Enter a number: "))
8+
9+
factorial = 1
10+
11+
# check if the number is negative, positive or zero
12+
if num < 0:
13+
print("Sorry, factorial does not exist for negative numbers")
14+
elif num == 0:
15+
print("The factorial of 0 is 1")
16+
else:
17+
for i in range(1,num + 1):
18+
factorial = factorial*i
19+
print("The factorial of",num,"is",factorial)

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.