Task

Take a   Natural Number   in a given base and return the sum of its digits:

   110         sums to   1
   123410   sums to   10
   fe16       sums to   29
   f0e16     sums to   29


procedure main(a)
    write(dsum(a[1]|1234,a[2]|10))
end
 
procedure dsum(n,b)
    n := integer((\b|10)||"r"||n)
    sum := 0
    while sum +:= (0 < n) % b do n /:= b
    return sum
end