Sum digits of an integer

From Fōrmulæ wiki
Jump to: navigation, search

This page is a solution to the task Sum digits of an integer in the Rosetta Code, written in Fōrmulæ.

Description (from Rosetta Code)

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

Program

SumDigitsOfAnIntegerCode.png

Use cases

SumDigitsOfAnIntegerCase01.png

SumDigitsOfAnIntegerCase02.png

SumDigitsOfAnIntegerCase03.png

SumDigitsOfAnIntegerCase04.png

Extras

The following is the plot of the function, to numbers 1 .. 300, in base 10:

SumDigitsOfAnIntegerCase05.png