Skip to content

Commit 9a3ac3c

Browse files
Merge branch 'master' into issue_9
2 parents 8d8c761 + ba41875 commit 9a3ac3c

File tree

4 files changed

+26
-0
lines changed

4 files changed

+26
-0
lines changed

Code/Factorial.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
x = input()
2+
ans = 1
3+
while(x>0):
4+
ans*=x
5+
x-=1
6+
7+
print ans

Code/binary.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#Taking user input
2+
num = input('Enter number: ')
3+
4+
#Diplay the output
5+
print('The binary equivalent is {0}'.format(bin(int(num))[2:]))

Code/binary_rec.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
def convertToBinary(n):
2+
"""Function to print binary number
3+
for the input decimal using recursion"""
4+
if n > 1:
5+
convertToBinary(n//2)
6+
print(n % 2,end = '')
7+
8+
# decimal number
9+
#Taking user input
10+
num = input('Enter number: ')
11+
12+
#Diplay the output
13+
convertToBinary(int(num))

Code/factorial.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
12
#program to find the factorial of a number provided by a user
23

34
if __name__ == "__main__":

0 commit comments

Comments
 (0)