Skip to content

Commit 4ddbd40

Browse files
author
Pc
committed
updated
1 parent 1eaab69 commit 4ddbd40

File tree

3 files changed

+34
-0
lines changed

3 files changed

+34
-0
lines changed

.DS_Store

0 Bytes
Binary file not shown.

Exercise/Exercise8.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
'''
2+
Enter a number : 5
3+
Required Output = factorial of 5 is : 120
4+
fill the <x> with your code
5+
5 fill in the blanks
6+
'''
7+
<1> factorial(number):
8+
if (number<=1):
9+
return 1
10+
else:
11+
return (<2>)
12+
13+
def main():
14+
inputNum = <3>(input("Enter a Number : "))
15+
print("factorial of "+<4>+" is :",<5>)
16+
17+
if __name__ == '__main__':
18+
main()

Solutions/Excercise8.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
'''
2+
Enter a number : 5
3+
Required Output = factorial of 5 is : 120
4+
'''
5+
def factorial(number):
6+
if (number<=1):
7+
return 1
8+
else:
9+
return (number*factorial(number-1))
10+
11+
def main():
12+
inputNum = int(input("Enter a Number : "))
13+
print("factorial of "+str(inputNum)+" is :",factorial(inputNum))
14+
15+
if __name__ == '__main__':
16+
main()

0 commit comments

Comments
 (0)