WLJS LogoWLJS Notebook

DigitSum

DigitSum[n] gives the sum of the decimal digits in the integer n.

DigitSum[n, b] gives the sum of the base b digits in the integer n.

DigitSum[n, b, k] gives the sum of the first k base b digits in the integer n.

DigitSum[n, b, -k] gives the sum of the last k base b digits in the integer n.

Examples

Sum digits of a number:

DigitSum[12345]
(* 15 *)

Please visit the official Wolfram Language Reference for more details.

On this page