Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- a = "1234345"
- b = "1239"
- c = 0
- r = []
- max = a.length > b.length ? a.length : b.length
- (1..max).each{ |i|
- n = a[-i].to_i + b[-i].to_i + c
- p n
- if n < 10 then
- c = 0
- r.unshift n
- else
- r.unshift n % 10
- c = n / 10
- end
- }
- p r.join
Add Comment
Please, Sign In to add comment