Last active
July 14, 2019 08:31
-
-
Save umair313/08bd97ca1bcb0fa26c6db54af2c6adec to your computer and use it in GitHub Desktop.
This program divide number with out division operator '/' and display it only . only divide integer numbers > 0 . In Python
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
a = 1467 #nomerator | |
b = 21 #denominator | |
count = 0 | |
flag = False | |
a_is_greater = False | |
floating_pre = 0 | |
if a > 0 and b > 0 and a > b: | |
a_is_greater = True | |
while b < a: | |
while count*b <= a: | |
count = count+1 | |
flag = True | |
count = count - 1 | |
a = a - (count * b) | |
print(count, end='') | |
if flag == False: | |
break | |
else: | |
count = 0 | |
flag = False | |
if b > 0 and a > 0 and b > a: | |
if a_is_greater: | |
print('.', end='') | |
else: | |
print('0.', end='') | |
while a < b : | |
floating_pre += 1 | |
while a < b: | |
a = a * 10 | |
while b < a: | |
while count * b <= a: | |
count = count + 1 | |
flag = True | |
count = count - 1 | |
a = a - (count * b) | |
print(count, end='') | |
if flag == False: | |
break | |
else: | |
count = 0 | |
flag = False | |
if floating_pre>5 or a == 0: | |
break | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment