Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save Marlysson/70e45c867afa0756d69d to your computer and use it in GitHub Desktop.
Save Marlysson/70e45c867afa0756d69d to your computer and use it in GitHub Desktop.
Operações somente com adição e subtração
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