-
Notifications
You must be signed in to change notification settings - Fork 0
/
bincon.py
53 lines (53 loc) · 879 Bytes
/
bincon.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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# bincon.py peter
# Convert a base 10 number to binary
#Use 191 base 10 equal to 1011 1111 base 2
# q(quotient) d(divisor) r(remainder) n(integer input)
# div 128
n = int(input("Input and integer less than 256 : "))
d = 128
q = int(n / d)
r = int(n % d)
print(d,q,r)
n = r
# div 64 * * * * * * *
d = int(d / 2)
q = int(n / d)
r = int(n % d)
print(d,q,r)
n = r
# div 32 * * * * * * *
d = int(d / 2)
q = int(n / d)
r = int(n % d)
print(d,q,r)
n = r
# div 16 * * * * * * *
d = int(d / 2)
q = int(n / d)
r = int(n % d)
print(d,q,r)
n = r
# div 8 * * * * * * *
d = int(d / 2)
q = int(n / d)
r = int(n % d)
print(d,q,r)
n = r
# div 4 * * * * * * *
d = int(d / 2)
q = int(n / d)
r = int(n % d)
print(d,q,r)
n = r
# div 2 * * * * * * *
d = int(d / 2)
q = int(n / d)
r = int(n % d)
print(d,q,r)
n = r
# div 1 * * * * * * *
d = int(d / 2)
q = int(n / d)
r = int(n % d)
print(d,q,r)
n = r