File tree Expand file tree Collapse file tree 1 file changed +2
-30
lines changed Expand file tree Collapse file tree 1 file changed +2
-30
lines changed Original file line number Diff line number Diff line change 1
- # this uses GPL V3 LICENSE
2
- # code by @JymPatel
3
-
4
- import sys
5
-
6
- binary = "$" # just starting var
7
- n = 15 # can get 2**16 numbers
8
-
9
- # get integer as output which is less than limit 2**16
10
- try :
11
- input = int (input ("What is your Decimal Number?" ))
12
- limit = 2 ** (n + 1 )
13
- input <= limit
14
- except ValueError :
15
- print ("Please put integer in input! & less than" , limit )
16
- sys .exit ()
17
-
18
- # main algorithm
19
- while n >= 0 :
20
- if input < 2 ** n :
21
- binary = binary + "0"
22
- else :
23
- binary = binary + "1"
24
- input = input - 2 ** n
25
- n = n - 1
26
-
27
- print (binary )
28
-
29
- # get it at https://github.com/JymPatel/Python3-FirstEdition
30
- print ("get it at https://github.com/JymPatel/Python3-FirstEdition" )
1
+ n = int (input ("Enter the number in decimal : " ))
2
+ print (int ((bin (n )[2 :])))
You can’t perform that action at this time.
0 commit comments