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


CARD FUNC SumDigits(CARD num,base)
  CARD res,a
 
  res=0
  WHILE num#0
  DO
    res==+num MOD base
    num=num/base
  OD
RETURN(res)
 
PROC Main()
  CARD ARRAY data=[
      1 10  1234 10  $FE 16  $F0E 16
      $FF 2  0 2  2186 3  2187 3]
  BYTE i
  CARD num,base,res
 
  FOR i=0 TO 15 STEP 2
  DO
    num=data(i)
    base=data(i+1)
    res=SumDigits(num,base)
    PrintF("num=%U base=%U sum=%U%E",num,base,res)
  OD
RETURN