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 (sum n base)
   (if (zero? n)
      n
      (+ (mod n base) (sum (div n base) base))))
 
(print (sum 1 10))
; ==> 1
 
(print (sum 1234 10))
; ==> 10
 
(print (sum #xfe 16))
; ==> 29
 
(print (sum #xf0e 16))
; ==> 29
 