Ruby, because Ruby has built-in divmod, because you need both at least as often as you need either.
divmod
def piecewise_add(n1, n2) return n1+n2 if n1*n2 == 0 d1, m1 = n1.divmod(10) d2, m2 = n2.divmod(10) m3 = m1+m2 mult = m3 > 9 ? 100 : 10 mult*piecewise_add(d1, d2)+m3 end
Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink.
Hide child comments as well
Confirm
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Ruby, because Ruby has built-in
divmod
, because you need both at least as often as you need either.