= Decimal counter
{title2=$A\in\{0,\ldots,9\}^k$}
A <decimal counter> stores a nonnegative <integer> using an <array> of base-ten <digits>, with the least significant <digit> first. Increment resets trailing nines and increases the next <digit>, or wraps modulo $10^k$ if all $k$ <digits> are nines. Starting at zero, the exact number of <digit> changes in $n$ increments is $\sum_{i=0}^{k-1}\lfloor n/10^i\rfloor\leq10n/9$. This is an <aggregate analysis> proving a constant <amortized cost> per increment under unit-cost <digit> updates. An arbitrary initial value contributes an additional $O(k)$ in <Big O notation>.
Back to article page