Created
August 14, 2012 14:47
-
-
Save jonatasemidio/3349935 to your computer and use it in GitHub Desktop.
Implementação da divisão sem divisão
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
#Eu sei que codigo ta porquinho, mas foi so para matar a curiosidade! rsrs | |
def d(): | |
do = int(raw_input('informe o dividendo: ')) | |
dr = int(raw_input('informe o divisor: ')) | |
m = do*dr | |
l = [] | |
while(m > 0): | |
l.append(m) | |
m -= dr | |
c = 0 | |
for i in l[::-1]: | |
c += 1 | |
if(i == do): | |
break | |
print 'resultado: '+str(c) if c == do/dr else 'divisor invalido!' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment