Advertisement
Guest User

Untitled

a guest
Feb 14th, 2018
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. def mult(a, b):
  2.     ret = 0
  3.    
  4.     sinalA = a < 0
  5.     if (sinalA == True):
  6.         a = -a
  7.  
  8.     sinalB = b < 0
  9.     if (sinalB == True):
  10.         b = -b
  11.    
  12.     sinal = 1 if (sinalA == sinalB) else -1
  13.    
  14.     if (a == 0):
  15.         ret = 0
  16.     else:
  17.         ret = b + mult(a-1, b)
  18.    
  19.     if (sinal == -1):
  20.         ret = -ret
  21.     return ret
  22. #############################################################
  23. vara = int(input(''))
  24. varb = int(input(''))
  25. print(mult(vara, varb))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement