PY
py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#Enter a number to get the numbers which have equal number of one's in binary and BCD representation with in the length of binary number.
'''Made for: BCD-BINARY-SUMMIT//DAILY-DOSE//upto max limit (input)
bcd of a decimal no.(Binary-Coded-Decimal)
eg: 167
bcd eqivalent-> 0001 0110 0111
binary eqivalent-> 10100111
TASK-->
if number of 1's in binary is equal to number of 1's in bcd ''upto that length''of binary (from right to left)
print the number,
print bcd eqiv,
print binary eqiv..
eg: 18---bcd 00011000 ( two 1's)
18--binary 10010 ( two 1's)
eg: 179---bcd 0001 01111001 ( five 1's)
179--binary 10110011 (five 1's)
'''
#BCD
def bcd(x):
s=''
while x>0:
t=x%10
Enter to Rename, Shift+Enter to Preview
OUTPUT
Run