The OEIS mourns the passing of Jim Simons and is grateful to the Simons Foundation for its support of research in many branches of science, including the OEIS.
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!)
A007953 Digital sum (i.e., sum of digits) of n; also called digsum(n). 1090

%I #280 Jun 18 2023 11:41:19

%S 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,

%T 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,

%U 7,8,9,10,11,12,13,14,15,7,8,9,10,11,12,13,14,15,16,8,9,10,11,12,13,14,15

%N Digital sum (i.e., sum of digits) of n; also called digsum(n).

%C Do not confuse with the digital root of n, A010888 (first term that differs is a(19)).

%C Also the fixed point of the morphism 0 -> {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}, 1 -> {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}, 2 -> {2, 3, 4, 5, 6, 7, 8, 9, 10, 11}, etc. - _Robert G. Wilson v_, Jul 27 2006

%C For n < 100 equal to (floor(n/10) + n mod 10) = A076314(n). - _Hieronymus Fischer_, Jun 17 2007

%C It appears that a(n) is the position of 10*n in the ordered set of numbers obtained by inserting/placing one digit anywhere in the digits of n (except a zero before 1st digit). For instance, for n=2, the resulting set is (12, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 32, 42, 52, 62, 72, 82, 92) where 20 is at position 2, so a(2) = 2. - _Michel Marcus_, Aug 01 2022

%C Also the total number of beads required to represent n on a Russian abacus (schoty). - _P. Christopher Staecker_, Mar 31 2023

%C a(n) / a(2n) <= 5 with equality iff n is in A169964, while a(n) / a(3n) is unbounded, since if n = (10^k + 2)/3, then a(n) = 3*k+1, a(3n) = 3, so a(n) / a(3n) = k + 1/3 -> oo when k->oo (see Diophante link). - _Bernard Schott_, Apr 29 2023

%D Krassimir Atanassov, On the 16th Smarandache Problem, Notes on Number Theory and Discrete Mathematics, Sophia, Bulgaria, Vol. 5 (1999), No. 1, 36-38.

%H N. J. A. Sloane, <a href="/A007953/b007953.txt">Table of n, a(n) for n = 0..10000</a>

%H Krassimir Atanassov, <a href="http://www.gallup.unm.edu/~smarandache/Atanassov-SomeProblems.pdf">On Some of Smarandache's Problems</a>.

%H Jean-Luc Baril, <a href="http://www.combinatorics.org/ojs/index.php/eljc/article/view/v18i1p178">Classical sequences revisited with permutations avoiding dotted pattern</a>, Electronic Journal of Combinatorics, Vol. 18 (2011), #P178.

%H F. M. Dekking, <a href="https://cs.uwaterloo.ca/journals/JIS/VOL26/Dekking/dek25.html">The Thue-Morse Sequence in Base 3/2</a>, J. Int. Seq., Vol. 26 (2023), Article 23.2.3.

%H Diophante, <a href="http://www.diophante.fr/problemes-par-themes/arithmetique-et-algebre/a1-pot-pourri/5453-a1762-des-chiffres-a-la-moulinette">A1762, Des chiffres à la moulinette</a> (in French).

%H Ernesto Estrada and Puri Pereira-Ramos, <a href="https://doi.org/10.1155/2018/9893867">Spatial 'Artistic' Networks: From Deconstructing Integer-Functions to Visual Arts</a>, Complexity, Vol. 2018 (2018), Article ID 9893867.

%H A. O. Gel'fond, <a href="http://matwbn.icm.edu.pl/ksiazki/aa/aa13/aa13115.pdf">Sur les nombres qui ont des propriétés additives et multiplicatives données</a> (French) Acta Arith., Vol. 13 (1967/1968), pp. 259-265. MR0220693 (36 #3745)

%H Christian Mauduit and András Sárközy, <a href="http://dx.doi.org/10.1006/jnth.1998.2229">On the arithmetic structure of sets characterized by sum of digits properties</a> J. Number Theory, Vol. 61 , No. 1 (1996), pp. 25-38. MR1418316 (97g:11107)

%H Christian Mauduit and András Sárközy, <a href="http://matwbn.icm.edu.pl/ksiazki/aa/aa81/aa8122.pdf"> On the arithmetic structure of the integers whose sum of digits is fixed</a>, Acta Arith., Vol. 81, No. 2 (1997), pp. 145-173. MR1456239 (99a:11096)

%H Kerry Mitchell, <a href="http://kerrymitchellart.com/articles/Spirolateral-Type_Images_from_Integer_Sequences.pdf">Spirolateral-Type Images from Integer Sequences</a>, 2013.

%H Kerry Mitchell, <a href="/A007953/a007953.jpg">Spirolateral image for this sequence</a> . [taken, with permission, from the Spirolateral-Type Images from Integer Sequences article]

%H Jan-Christoph Puchta and Jürgen Spilker, <a href="http://dx.doi.org/10.1007/s00591-002-0048-4">Altes und Neues zur Quersumme</a>, Mathematische Semesterberichte, Vol. 49 (2002), pp. 209-226.

%H Jan-Christoph Puchta and Jürgen Spilker, <a href="http://www.math.uni-rostock.de/~schlage-puchta/papers/Quersumme.pdf">Altes und Neues zur Quersumme</a>.

%H Maxwell Schneider and Robert Schneider, <a href="https://arxiv.org/abs/1807.06710">Digit sums and generating functions</a>, arXiv:1807.06710 [math.NT], 2018.

%H Jeffrey O. Shallit, <a href="http://www.jstor.org/stable/2322179">Problem 6450</a>, Advanced Problems, The American Mathematical Monthly, Vol. 91, No. 1 (1984), pp. 59-60; <a href="http://www.jstor.org/stable/2322523">Two series, solution to Problem 6450</a>, ibid., Vol. 92, No. 7 (1985), pp. 513-514.

%H Vladimir Shevelev, <a href="http://journals.impan.pl/aa/Inf/126-3-1.html">Compact integers and factorials</a>, Acta Arith., Vol. 126, No. 3 (2007), pp. 195-236 (cf. pp. 205-206).

%H Robert Walker, <a href="http://robertinventor.com/ftswiki/Self_Similar_Sloth_Canon_Number_Sequences">Self Similar Sloth Canon Number Sequences</a>.

%H Eric Weisstein's World of Mathematics, <a href="http://mathworld.wolfram.com/DigitSum.html">Digit Sum</a>.

%H Wikipedia, <a href="http://en.wikipedia.org/wiki/Digit_sum">Digit sum</a>.

%H <a href="/index/Coi#Colombian">Index entries for Colombian or self numbers and related sequences</a>

%F a(A051885(n)) = n.

%F a(n) <= 9(log_10(n)+1). - _Stefan Steinerberger_, Mar 24 2006

%F From _Benoit Cloitre_, Dec 19 2002: (Start)

%F a(0) = 0, a(10n+i) = a(n) + i for 0 <= i <= 9.

%F a(n) = n - 9*(Sum_{k > 0} floor(n/10^k)) = n - 9*A054899(n). (End)

%F From _Hieronymus Fischer_, Jun 17 2007: (Start)

%F G.f. g(x) = Sum_{k > 0, (x^k - x^(k+10^k) - 9x^(10^k))/(1-x^(10^k))}/(1-x).

%F a(n) = n - 9*Sum_{10 <= k <= n} Sum_{j|k, j >= 10} floor(log_10(j)) - floor(log_10(j-1)). (End)

%F From _Hieronymus Fischer_, Jun 25 2007: (Start)

%F The g.f. can be expressed in terms of a Lambert series, in that g(x) = (x/(1-x) - 9*L[b(k)](x))/(1-x) where L[b(k)](x) = sum{k >= 0, b(k)*x^k/(1-x^k)} is a Lambert series with b(k) = 1, if k > 1 is a power of 10, else b(k) = 0.

%F G.f.: g(x) = (Sum_{k > 0} (1 - 9*c(k))*x^k)/(1-x), where c(k) = Sum_{j > 1, j|k} floor(log_10(j)) - floor(log_10(j-1)).

%F a(n) = n - 9*Sum_{0 < k <= floor(log_10(n))} a(floor(n/10^k))*10^(k-1). (End)

%F From _Hieronymus Fischer_, Oct 06 2007: (Start)

%F a(n) <= 9*(1 + floor(log_10(n)), equality holds for n = 10^m - 1, m > 0.

%F lim sup (a(n) - 9*log_10(n)) = 0 for n -> oo.

%F lim inf (a(n+1) - a(n) + 9*log_10(n)) = 1 for n -> oo. (End)

%F a(n) = A138530(n, 10) for n > 9. - _Reinhard Zumkeller_, Mar 26 2008

%F a(A058369(n)) = A004159(A058369(n)); a(A000290(n)) = A004159(n). - _Reinhard Zumkeller_, Apr 25 2009

%F a(n) mod 2 = A179081(n). - _Reinhard Zumkeller_, Jun 28 2010

%F a(n) <= 9*log_10(n+1). - _Vladimir Shevelev_, Jun 01 2011

%F a(n) = a(n-1) + a(n-10) - a(n-11), for n < 100. - _Alexander R. Povolotsky_, Oct 09 2011

%F a(n) = Sum_{k >= 0} A031298(n, k). - _Philippe Deléham_, Oct 21 2011

%F a(n) = a(n mod b^k) + a(floor(n/b^k)), for all k >= 0. - _Hieronymus Fischer_, Mar 24 2014

%F Sum_{n>=1} a(n)/(n*(n+1)) = 10*log(10)/9 (Shallit, 1984). - _Amiram Eldar_, Jun 03 2021

%e a(123) = 1 + 2 + 3 = 6, a(9875) = 9 + 8 + 7 + 5 = 29.

%p A007953 := proc(n) add(d,d=convert(n,base,10)) ; end proc: # _R. J. Mathar_, Mar 17 2011

%t Table[Sum[DigitCount[n][[i]] * i, {i, 9}], {n, 50}] (* _Stefan Steinerberger_, Mar 24 2006 *)

%t Table[Plus @@ IntegerDigits @ n, {n, 0, 87}] (* or *)

%t Nest[Flatten[# /. a_Integer -> Array[a + # &, 10, 0]] &, {0}, 2] (* _Robert G. Wilson v_, Jul 27 2006 *)

%t Total/@IntegerDigits[Range[0,90]] (* _Harvey P. Dale_, May 10 2016 *)

%o /* The next few PARI programs are kept for historical and pedagogical reasons.

%o For practical use, the suggested and most efficient code is: A007953=sumdigits */

%o (PARI) a(n)=if(n<1, 0, if(n%10, a(n-1)+1, a(n/10))) \\ Recursive, very inefficient. A more efficient recursive variant: a(n)=if(n>9, n=divrem(n, 10); n[2]+a(n[1]), n)

%o (PARI) a(n, b=10)={my(s=(n=divrem(n, b))[2]); while(n[1]>=b, s+=(n=divrem(n[1], b))[2]); s+n[1]} \\ _M. F. Hasler_, Mar 22 2011

%o (PARI) a(n)=sum(i=1, #n=digits(n), n[i]) \\ Twice as fast. Not so nice but faster:

%o (PARI) a(n)=sum(i=1,#n=Vecsmall(Str(n)),n[i])-48*#n \\ - _M. F. Hasler_, May 10 2015

%o /* Since PARI 2.7, one can also use: a(n)=vecsum(digits(n)), or better: A007953=sumdigits. [Edited and commented by _M. F. Hasler_, Nov 09 2018] */

%o (PARI) a(n) = sumdigits(n); \\ _Altug Alkan_, Apr 19 2018

%o (Haskell)

%o a007953 n | n < 10 = n

%o | otherwise = a007953 n' + r where (n',r) = divMod n 10

%o -- _Reinhard Zumkeller_, Nov 04 2011, Mar 19 2011

%o (Magma) [ &+Intseq(n): n in [0..87] ]; // _Bruno Berselli_, May 26 2011

%o (Smalltalk)

%o "Recursive version for general bases. Set base = 10 for this sequence."

%o digitalSum: base

%o | s |

%o base = 1 ifTrue: [^self].

%o (s := self // base) > 0

%o ifTrue: [^(s digitalSum: base) + self - (s * base)]

%o ifFalse: [^self]

%o "by _Hieronymus Fischer_, Mar 24 2014"

%o (Python)

%o def A007953(n):

%o return sum(int(d) for d in str(n)) # _Chai Wah Wu_, Sep 03 2014

%o (Python)

%o def a(n): return sum(map(int, str(n))) # _Michael S. Branicky_, May 22 2021

%o (Scala) (0 to 99).map(_.toString.map(_.toInt - 48).sum) // _Alonso del Arte_, Sep 15 2019

%o (Swift)

%o A007953(n): String(n).compactMap{$0.wholeNumberValue}.reduce(0, +) // _Egor Khmara_, Jun 15 2021

%Y Cf. A003132, A055012, A055013, A055014, A055015, A010888, A007954, A031347, A055017, A076313, A076314, A054899, A138470, A138471, A138472, A000120, A004426, A004427, A054683, A054684, A069877, A179082-A179085, A108971, A169964, A179987, A179988, A180018, A180019, A217928, A216407, A037123, A074784, A231688, A231689, A225693, A254524 (ordinal transform).

%Y Bisections: A004092, A004155.

%Y For n + digsum(n) see A062028.

%K nonn,base,nice,easy,look

%O 0,3

%A R. Muller

%E More terms from _Hieronymus Fischer_, Jun 17 2007

%E Edited by _Michel Marcus_, Nov 11 2013

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 May 13 16:16 EDT 2024. Contains 372522 sequences. (Running on oeis4.)