Home

totalsiffror

Totalsiffror is a term used in Swedish mathematics and computer science that can refer to two related notions involving digit counts. In one sense, totalsiffror denotes the number of digits in a single positive integer. In another sense, it denotes the total number of digits required to write all integers in a given range, typically from 1 up to some n.

For a positive integer n, the number of digits in its decimal representation is digits(n) = floor(log10(n))

The range interpretation, often called the total number of digits from 1 to n, is denoted D(n)

Examples help illustrate: D(13) = 13 (1–9 contribute 9 digits, 10–13 contribute 4 digits). D(99) = 189. D(999)

Totalsiffror appears in problems about counting digits, numeral systems, and algorithm analysis where the cost is

+
1.
Equivalently,
this
is
the
length
of
n
when
written
in
base-10
without
leading
zeros.
For
example,
digits(7)
=
1,
digits(42)
=
2,
and
digits(1234)
=
4.
=
sum_{k=1}^n
digits(k).
A
commonly
used
closed-form
expression
for
D(n)
uses
m
=
floor(log10(n))
+
1,
the
number
of
digits
in
n.
Then
D(n)
=
sum_{i=1}^{m-1}
9·10^{i-1}·i
+
(n
−
10^{m-1}
+
1)·m.
This
accounts
for
all
full
blocks
of
1-digit
numbers
(1–9),
2-digit
numbers
(10–99),
and
so
on,
plus
the
partial
block
ending
at
n.
=
2889.
expressed
in
the
number
of
digits
processed.
Related
topics
include
digit
sums,
base-10
representation,
and
logarithmic
growth.