sum digits of a number in a given base