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


function sum_digits(integer n, integer base)
integer res = 0
    while n do
        res += remainder(n,base)
        n = floor(n/base)
    end while
    return res
end function
 
?sum_digits(1,10)
?sum_digits(1234,10)
?sum_digits(#FE,16)
?sum_digits(#F0E,16)
