cp's OEIS Frontend

This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.

A321999 Sum of digits of n minus the number of digits of n.

This page as a plain text file.
%I A321999 #23 Dec 27 2022 18:47:13
%S A321999 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,
%T A321999 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,
%U A321999 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
%N A321999 Sum of digits of n minus the number of digits of n.
%C A321999 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.
%H A321999 Harvey P. Dale, <a href="/A321999/b321999.txt">Table of n, a(n) for n = 0..1000</a>
%F A321999 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:
%F A321999 a(10^k) = -k for all k >= 0. a(m) = m - 1 for 0 < m < 10.
%F A321999 a(n+1) = a(n) + 1 unless n = 9 (mod 10), in which case a(n+1) = a((n+1)/10).
%F A321999 a(10^k-1) = 8*k.
%e A321999 a(0) = 0 - 0 = 0. (We consider 0 has 0 digits.)
%e A321999 a(1) = 1 - 1 = 0;
%e A321999 a(2) = 2 - 1 = 1, ...,
%e A321999 a(9) = 9 - 1 = 8. (General formula: a(10^k - 1) = 8*k.)
%e A321999 a(10) = 1 - 2 = -1. (General formula: a(10^k) = -k.)
%e A321999 a(11) = 1+1 - 2 = 0, ...,
%e A321999 a(19) = 1+9 - 2 = 8;
%e A321999 a(20) = 2+0 - 2 = 0. (General formula: a(m*10^k) = a(m) - k.)
%e A321999 a(29) = 2+9 - 2 = 9, ...,
%e A321999 a(99) = 9+9 - 2 = 16: cf. a(9);
%e A321999 a(100) = 1+0+0 - 3 = -2;
%e A321999 a(101) = 1+0+1 - 3 = -1;
%e A321999 a(102) = 1+0+2 - 3 = 0, ...,
%e A321999 a(109) = 1+0+9 - 3 = 7;
%e A321999 a(110) = 1+1+0 - 3 = -1, ...,
%e A321999 a(119) = 1+1+9 - 3 = 8, ...,
%e A321999 a(199) = 1+9+9 - 3 = 16,
%e A321999 a(200) = 2+0+0 - 3 = -1: cf. a(20), ...,
%e A321999 a(999) = 9+9+9 - 3 = 24: cf. a(9);
%e A321999 a(1000) = 1+0+0+0 - 4 = -3, ...,
%e A321999 a(1001) = 1+0+0+1 - 4 = -2, ....
%p A321999 a:= n-> add(i, i=convert(n, base, 10))-length(n):
%p A321999 seq(a(n), n=0..100);  # _Alois P. Heinz_, Dec 10 2018
%t A321999 Table[(Plus@@IntegerDigits[n]) - Length[IntegerDigits[n]] + KroneckerDelta[n, 0], {n, 0, 99}] (* _Alonso del Arte_, Dec 07 2018 *)
%t A321999 Table[Total[IntegerDigits[n]]-IntegerLength[n],{n,0,100}] (* _Harvey P. Dale_, Dec 27 2022 *)
%o A321999 (PARI) A321999(n)=sumdigits(n)-if(n,logint(n,10)+1)
%Y A321999 Cf. A007953 (digit sum of n), A004218 (ceiling(log_10(n))), A055642 (number of digits of n).
%Y A321999 The zeroes of this sequence, except 0 itself, are in A061384.
%K A321999 base,sign
%O A321999 0,4
%A A321999 _M. F. Hasler_, Dec 07 2018