Algosim documentation: digits

digits

Returns the digits of an integer or a rational number.

Syntax

Description

Examples

digits(521341)
5
2
1
3
4
1
#digits(1852616517806850212)
19
digits(1/613)
int: (0)
frac: (0, 0, 1, 6, 3, 1, 3, 2, 1, 3, 7, 0, 3, 0, 9, 9, 5, 1, 0, 6, 0, 3, 5, 8, 8, 9, 0, 7, 0, 1, 4, 6, 8, 1, 8, 9, 2, 3, 3, 2, 7, 8, 9, 5, 5, 9, 5, 4, 3, 2, 3, 0, 0, 1, 6, 3, 1, 3, 2, 1, 3, 7, 0, 3)
sort(frequencies(digits(1/123456789, 1E6).frac))
(0, 100177)
(1, 99612)
(2, 100115)
(3, 100281)
(4, 100006)
(5, 100022)
(6, 99586)
(7, 99791)
(8, 100175)
(9, 100235)
sort(frequencies(compute(RandomInt(1000000)^2, n, 1, 1000000) @ digits @ first))
(1, 192164)
(2, 146925)
(3, 123873)
(4, 109158)
(5, 98564)
(6, 90439)
(7, 84566)
(8, 79092)
(9, 75219)