login
The OEIS is supported by the many generous donors to the OEIS Foundation.

 

Logo
Hints
(Greetings from The On-Line Encyclopedia of Integer Sequences!)
A321999 Sum of digits of n minus the number of digits of n. 1
0, 0, 1, 2, 3, 4, 5, 6, 7, 8, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 7 (list; graph; refs; listen; history; text; internal format)
OFFSET
0,4
COMMENTS
Concerning 0 we use the convention that 0 has 0 digits, so a(0) = 0 - 0 = 0, a(1) = 1 - 1 = 0, and a(10) = 1 - 2 = -1 is the first negative terms of the sequence.
LINKS
FORMULA
a(n) = A007953(n) - A004218(n+1) = A007953(n) - A055642(n) for all n > 0. a(m*10^k) = a(m) - k for all m > 0, k >= 0, in particular:
a(10^k) = -k for all k >= 0. a(m) = m - 1 for 0 < m < 10.
a(n+1) = a(n) + 1 unless n = 9 (mod 10), in which case a(n+1) = a((n+1)/10).
a(10^k-1) = 8*k.
EXAMPLE
a(0) = 0 - 0 = 0. (We consider 0 has 0 digits.)
a(1) = 1 - 1 = 0;
a(2) = 2 - 1 = 1, ...,
a(9) = 9 - 1 = 8. (General formula: a(10^k - 1) = 8*k.)
a(10) = 1 - 2 = -1. (General formula: a(10^k) = -k.)
a(11) = 1+1 - 2 = 0, ...,
a(19) = 1+9 - 2 = 8;
a(20) = 2+0 - 2 = 0. (General formula: a(m*10^k) = a(m) - k.)
a(29) = 2+9 - 2 = 9, ...,
a(99) = 9+9 - 2 = 16: cf. a(9);
a(100) = 1+0+0 - 3 = -2;
a(101) = 1+0+1 - 3 = -1;
a(102) = 1+0+2 - 3 = 0, ...,
a(109) = 1+0+9 - 3 = 7;
a(110) = 1+1+0 - 3 = -1, ...,
a(119) = 1+1+9 - 3 = 8, ...,
a(199) = 1+9+9 - 3 = 16,
a(200) = 2+0+0 - 3 = -1: cf. a(20), ...,
a(999) = 9+9+9 - 3 = 24: cf. a(9);
a(1000) = 1+0+0+0 - 4 = -3, ...,
a(1001) = 1+0+0+1 - 4 = -2, ....
MAPLE
a:= n-> add(i, i=convert(n, base, 10))-length(n):
seq(a(n), n=0..100); # Alois P. Heinz, Dec 10 2018
MATHEMATICA
Table[(Plus@@IntegerDigits[n]) - Length[IntegerDigits[n]] + KroneckerDelta[n, 0], {n, 0, 99}] (* Alonso del Arte, Dec 07 2018 *)
Table[Total[IntegerDigits[n]]-IntegerLength[n], {n, 0, 100}] (* Harvey P. Dale, Dec 27 2022 *)
PROG
(PARI) A321999(n)=sumdigits(n)-if(n, logint(n, 10)+1)
CROSSREFS
Cf. A007953 (digit sum of n), A004218 (ceiling(log_10(n))), A055642 (number of digits of n).
The zeroes of this sequence, except 0 itself, are in A061384.
Sequence in context: A256289 A031076 A346732 * A228822 A255829 A277547
KEYWORD
base,sign
AUTHOR
M. F. Hasler, Dec 07 2018
STATUS
approved

Lookup | Welcome | Wiki | Register | Music | Plot 2 | Demos | Index | Browse | More | WebCam
Contribute new seq. or comment | Format | Style Sheet | Transforms | Superseeker | Recents
The OEIS Community | Maintained by The OEIS Foundation Inc.

License Agreements, Terms of Use, Privacy Policy. .

Last modified September 15 03:00 EDT 2024. Contains 375931 sequences. (Running on oeis4.)