brewersfan1976

addition_without_carrying.rb

Sep 24th, 2016
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 0.31 KB | None | 0 0
  1. def additionWithoutCarrying(param1, param2)
  2.     result = 0
  3.     ten_power = 1
  4.    
  5.     while (param1 > 0 or param2 > 0)
  6.           result = result + ten_power * ((param1 + param2) % 10)
  7.           param1 /= 10
  8.           param2 /= 10
  9.           ten_power = ten_power * 10
  10.     end
  11.    
  12.     return result
  13. end
Advertisement
Add Comment
Please, Sign In to add comment