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


define s(n) {
    auto i, o, s
 
    o = scale
    scale = 0
 
    for (i = n; i > 0; i /= ibase) {
        s += i % ibase
    }
 
    scale = o
    return(s)
}
 
ibase = 10
s(1)
s(1234)
ibase = 16
s(FE)
s(F0E)