Skip to content

DigitSum

The sum of the digits of n in the given base (default 10).

DigitSum(n)sum of the digits of , base 10.
DigitSum(n, base)sum of the digits of in the given base.

Domain: Number theory

Details
  • Equivalent to summing IntegerDigits(n, base).
  • In base 2, the digit sum is the number of set bits (population count).
  • in base 10 -- the basis of the classic divisibility-by-9 check and digital root.
  • The sign of n is discarded before summing.
  • compute-engine only supports the 2-argument form.

Examples

See also: DigitCount