Last active
October 30, 2015 21:13
-
-
Save Marlysson/70e45c867afa0756d69d to your computer and use it in GitHub Desktop.
Operações somente com adição e subtraçã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
def soma(n1,n2): | |
return n1+n2 | |
def subtr(n1,n2): | |
return n1-n2 | |
def mult(n1,n2): | |
result = 0 | |
for i in range(1,n2+1): | |
result += soma(n1,0); | |
return result | |
def div(n1,n2): | |
result = max(n1,n2) | |
cont = 0 | |
while (result > 0): | |
result = subtr(n1,n2) | |
n1 = result | |
if result >= 0: | |
cont += 1 | |
else: | |
resto = max(n1,n2) - mult(min(n1,n2),cont) | |
break | |
return {'result':cont,'resto':resto} | |
print mult(10,5) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment