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.

Showing 1-10 of 18 results. Next

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

Original entry on oeis.org

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, 8, 9, 10, 11, 12, 13, 14, 15, 16, 8, 9, 10, 11, 12, 13, 14, 15
Offset: 0

Views

Author

R. Muller

Keywords

Comments

Do not confuse with the digital root of n, A010888 (first term that differs is a(19)).
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
For n < 100 equal to (floor(n/10) + n mod 10) = A076314(n). - Hieronymus Fischer, Jun 17 2007
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
Also the total number of beads required to represent n on a Russian abacus (schoty). - P. Christopher Staecker, Mar 31 2023
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
Also the number of symbols needed to write number n in Egyptian numerals for n < 10^7. - Wojciech Graj, Jul 10 2025

Examples

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

Crossrefs

Programs

  • Haskell
    a007953 n | n < 10 = n
              | otherwise = a007953 n' + r where (n',r) = divMod n 10
    -- Reinhard Zumkeller, Nov 04 2011, Mar 19 2011
    
  • Magma
    [ &+Intseq(n): n in [0..87] ];  // Bruno Berselli, May 26 2011
    
  • Maple
    A007953 := proc(n) add(d,d=convert(n,base,10)) ; end proc: # R. J. Mathar, Mar 17 2011
  • Mathematica
    Table[Sum[DigitCount[n][[i]] * i, {i, 9}], {n, 50}] (* Stefan Steinerberger, Mar 24 2006 *)
    Table[Plus @@ IntegerDigits @ n, {n, 0, 87}] (* or *)
    Nest[Flatten[# /. a_Integer -> Array[a + # &, 10, 0]] &, {0}, 2] (* Robert G. Wilson v, Jul 27 2006 *)
    Total/@IntegerDigits[Range[0,90]] (* Harvey P. Dale, May 10 2016 *)
    DigitSum[Range[0, 100]] (* Requires v. 14 *) (* Paolo Xausa, May 17 2024 *)
  • 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)
    
  • 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
    
  • PARI
    a(n)=sum(i=1, #n=digits(n), n[i]) \\ Twice as fast. Not so nice but faster:
    
  • PARI
    a(n)=sum(i=1,#n=Vecsmall(Str(n)),n[i])-48*#n \\ M. F. Hasler, May 10 2015
    /* 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] */
    
  • PARI
    a(n) = sumdigits(n); \\ Altug Alkan, Apr 19 2018
    
  • Python
    def A007953(n):
        return sum(int(d) for d in str(n)) # Chai Wah Wu, Sep 03 2014
    
  • Python
    def a(n): return sum(map(int, str(n))) # Michael S. Branicky, May 22 2021
    
  • Scala
    (0 to 99).map(.toString.map(.toInt - 48).sum) // Alonso del Arte, Sep 15 2019
    
  • Smalltalk
    "Recursive version for general bases. Set base = 10 for this sequence."
    digitalSum: base
    | s |
    base = 1 ifTrue: [^self].
    (s := self // base) > 0
      ifTrue: [^(s digitalSum: base) + self - (s * base)]
      ifFalse: [^self]
    "by Hieronymus Fischer, Mar 24 2014"
    
  • Swift
    A007953(n): String(n).compactMap{$0.wholeNumberValue}.reduce(0, +) // Egor Khmara, Jun 15 2021

Formula

a(A051885(n)) = n.
a(n) <= 9(log_10(n)+1). - Stefan Steinerberger, Mar 24 2006
From Benoit Cloitre, Dec 19 2002: (Start)
a(0) = 0, a(10n+i) = a(n) + i for 0 <= i <= 9.
a(n) = n - 9*(Sum_{k > 0} floor(n/10^k)) = n - 9*A054899(n). (End)
From Hieronymus Fischer, Jun 17 2007: (Start)
G.f. g(x) = Sum_{k > 0, (x^k - x^(k+10^k) - 9x^(10^k))/(1-x^(10^k))}/(1-x).
a(n) = n - 9*Sum_{10 <= k <= n} Sum_{j|k, j >= 10} floor(log_10(j)) - floor(log_10(j-1)). (End)
From Hieronymus Fischer, Jun 25 2007: (Start)
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.
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)).
a(n) = n - 9*Sum_{0 < k <= floor(log_10(n))} a(floor(n/10^k))*10^(k-1). (End)
From Hieronymus Fischer, Oct 06 2007: (Start)
a(n) <= 9*(1 + floor(log_10(n))), equality holds for n = 10^m - 1, m > 0.
lim sup (a(n) - 9*log_10(n)) = 0 for n -> oo.
lim inf (a(n+1) - a(n) + 9*log_10(n)) = 1 for n -> oo. (End)
a(n) = A138530(n, 10) for n > 9. - Reinhard Zumkeller, Mar 26 2008
a(A058369(n)) = A004159(A058369(n)); a(A000290(n)) = A004159(n). - Reinhard Zumkeller, Apr 25 2009
a(n) mod 2 = A179081(n). - Reinhard Zumkeller, Jun 28 2010
a(n) <= 9*log_10(n+1). - Vladimir Shevelev, Jun 01 2011
a(n) = a(n-1) + a(n-10) - a(n-11), for n < 100. - Alexander R. Povolotsky, Oct 09 2011
a(n) = Sum_{k >= 0} A031298(n, k). - Philippe Deléham, Oct 21 2011
a(n) = a(n mod b^k) + a(floor(n/b^k)), for all k >= 0. - Hieronymus Fischer, Mar 24 2014
Sum_{n>=1} a(n)/(n*(n+1)) = 10*log(10)/9 (Shallit, 1984). - Amiram Eldar, Jun 03 2021

Extensions

More terms from Hieronymus Fischer, Jun 17 2007
Edited by Michel Marcus, Nov 11 2013

A101296 n has the a(n)-th distinct prime signature.

Original entry on oeis.org

1, 2, 2, 3, 2, 4, 2, 5, 3, 4, 2, 6, 2, 4, 4, 7, 2, 6, 2, 6, 4, 4, 2, 8, 3, 4, 5, 6, 2, 9, 2, 10, 4, 4, 4, 11, 2, 4, 4, 8, 2, 9, 2, 6, 6, 4, 2, 12, 3, 6, 4, 6, 2, 8, 4, 8, 4, 4, 2, 13, 2, 4, 6, 14, 4, 9, 2, 6, 4, 9, 2, 15, 2, 4, 6, 6, 4, 9, 2, 12, 7, 4, 2, 13, 4, 4, 4, 8, 2, 13, 4, 6, 4, 4, 4, 16, 2, 6, 6, 11, 2, 9, 2, 8, 9, 4, 2, 15, 2, 9, 4, 12, 2, 9, 4, 6, 6, 4, 4, 17
Offset: 1

Views

Author

David Wasserman, Dec 21 2004

Keywords

Comments

From Antti Karttunen, May 12 2017: (Start)
Restricted growth sequence transform of A046523, the least representative of each prime signature. Thus this partitions the natural numbers to the same equivalence classes as A046523, i.e., for all i, j: a(i) = a(j) <=> A046523(i) = A046523(j), and for that reason satisfies in that respect all the same conditions as A046523. For example, we have, for all i, j: if a(i) = a(j), then:
A000005(i) = A000005(j), A008683(i) = A008683(j), A286605(i) = A286605(j).
So, this sequence (instead of A046523) can be used for finding sequences where a(n)'s value is dependent only on the prime signature of n, that is, only on the multiset of prime exponents in the factorization of n. (End)
This is also the restricted growth sequence transform of many other sequences, for example, that of A181819. See further comments there. - Antti Karttunen, Apr 30 2022

Examples

			From _David A. Corneth_, May 12 2017: (Start)
1 has prime signature (), the first distinct prime signature. Therefore, a(1) = 1.
2 has prime signature (1), the second distinct prime signature after (1). Therefore, a(2) = 2.
3 has prime signature (1), as does 2. Therefore, a(3) = a(2) = 2.
4 has prime signature (2), the third distinct prime signature after () and (1). Therefore, a(4) = 3. (End)
From _Antti Karttunen_, May 12 2017: (Start)
Construction of restricted growth sequences: In this case we start with a(1) = 1 for A046523(1) = 1, and thereafter, for all n > 1, we use the least so far unused natural number k for a(n) if A046523(n) has not been encountered before, otherwise [whenever A046523(n) = A046523(m), for some m < n], we set a(n) = a(m).
For n = 2, A046523(2) = 2, which has not been encountered before (first prime), thus we allot for a(2) the least so far unused number, which is 2, thus a(2) = 2.
For n = 3, A046523(2) = 2, which was already encountered as A046523(1), thus we set a(3) = a(2) = 2.
For n = 4, A046523(4) = 4, not encountered before (first square of prime), thus we allot for a(4) the least so far unused number, which is 3, thus a(4) = 3.
For n = 5, A046523(5) = 2, as for the first time encountered at n = 2, thus we set a(5) = a(2) = 2.
For n = 6, A046523(6) = 6, not encountered before (first semiprime pq with distinct p and q), thus we allot for a(6) the least so far unused number, which is 4, thus a(6) = 4.
For n = 8, A046523(8) = 8, not encountered before (first cube of a prime), thus we allot for a(8) the least so far unused number, which is 5, thus a(8) = 5.
For n = 9, A046523(9) = 4, as for the first time encountered at n = 4, thus a(9) = 3.
(End)
From _David A. Corneth_, May 12 2017: (Start)
(Rough) description of an algorithm of computing the sequence:
Suppose we want to compute a(n) for n in [1..20].
We set up a vector of 20 elements, values 0, and a number m = 1, the minimum number we haven't checked and c = 0, the number of distinct prime signatures we've found so far.
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
We check the prime signature of m and see that it's (). We increase c with 1 and set all elements up to 20 with prime signature () to 1. In the process, we adjust m. This gives:
[1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]. The least number we haven't checked is m = 2. 2 has prime signature (1). We increase c with 1 and set all elements up to 20 with prime signature (1) to 2. In the process, we adjust m. This gives:
[1, 2, 2, 0, 2, 0, 2, 0, 0, 0, 2, 0, 2, 0, 0, 0, 2, 0, 2, 0]
We check the prime signature of m = 4 and see that its prime signature is (2). We increase c with 1 and set all numbers up to 20 with prime signature (2) to 3. This gives:
[1, 2, 2, 3, 2, 0, 2, 0, 3, 0, 2, 0, 2, 0, 0, 0, 2, 0, 2, 0]
Similarily, after m = 6, we get
[1, 2, 2, 3, 2, 4, 2, 0, 3, 4, 2, 0, 2, 4, 4, 0, 2, 0, 2, 0], after m = 8 we get:
[1, 2, 2, 3, 2, 4, 2, 5, 3, 4, 2, 0, 2, 4, 4, 0, 2, 0, 2, 0], after m = 12 we get:
[1, 2, 2, 3, 2, 4, 2, 5, 3, 4, 2, 6, 2, 4, 4, 0, 2, 6, 2, 0], after m = 16 we get:
[1, 2, 2, 3, 2, 4, 2, 5, 3, 4, 2, 6, 2, 4, 4, 7, 2, 6, 2, 0], after m = 20 we get:
[1, 2, 2, 3, 2, 4, 2, 5, 3, 4, 2, 6, 2, 4, 4, 7, 2, 6, 2, 8]. Now, m > 20 so we stop. (End)
The above method is inefficient, because the step "set all elements a(n) up to n = Nmax with prime signature s(n) = S[c] to c" requires factoring all integers up to Nmax (or at least comparing their signature, once computed, with S[c]) again and again. It is much more efficient to run only once over each m = 1..Nmax, compute its prime signature s(m), add it to an ordered list in case it did not occur earlier, together with its "rank" (= new size of the list), and assign that rank to a(m). The list of prime signatures is much shorter than [1..Nmax]. One can also use m'(m) := the smallest n with the prime signature of m (which is faster to compute than to search for the signature) as representative for s(m), and set a(m) := a(m'(m)). Then it is sufficient to have just one counter (number of prime signatures seen so far) as auxiliary variable, in addition to the sequence to be computed. - _M. F. Hasler_, Jul 18 2019
		

Crossrefs

Cf. A025487, A046523, A064839 (ordinal transform of this sequence), A181819, and arrays A095904, A179216.
Sequences that are unions of finite number (>= 2) of equivalence classes determined by the values that this sequence obtains (i.e., sequences mentioned in David A. Corneth's May 12 2017 formula): A001358 (A001248 U A006881, values 3 & 4), A007422 (values 1, 4, 5), A007964 (2, 3, 4, 5), A014612 (5, 6, 9), A030513 (4, 5), A037143 (1, 2, 3, 4), A037144 (1, 2, 3, 4, 5, 6, 9), A080258 (6, 7), A084116 (2, 4, 5), A167171 (2, 4), A217856 (6, 9).
Cf. also A077462, A305897 (stricter variants, with finer partitioning) and A254524, A286603, A286605, A286610, A286619, A286621, A286622, A286626, A286378 for other similarly constructed sequences.

Programs

  • Maple
    A101296 := proc(n)
        local a046523, a;
        a046523 := A046523(n) ;
        for a from 1 do
            if A025487(a) = a046523 then
                return a;
            elif A025487(a) > a046523 then
                return -1 ;
            end if;
        end do:
    end proc: # R. J. Mathar, May 26 2017
  • Mathematica
    With[{nn = 120}, Function[s, Table[Position[Keys@s, k_ /; MemberQ[k, n]][[1, 1]], {n, nn}]]@ Map[#1 -> #2 & @@ # &, Transpose@ {Values@ #, Keys@ #}] &@ PositionIndex@ Table[Times @@ MapIndexed[Prime[First@ #2]^#1 &, Sort[FactorInteger[n][[All, -1]], Greater]] - Boole[n == 1], {n, nn}] ] (* Michael De Vlieger, May 12 2017, Version 10 *)
  • PARI
    find(ps, vps) = {for (k=1, #vps, if (vps[k] == ps, return(k)););}
    lisps(nn) = {vps = []; for (n=1, nn, ps = vecsort(factor(n)[,2]); ips = find(ps, vps); if (! ips, vps = concat(vps, ps); ips = #vps); print1(ips, ", "););} \\ Michel Marcus, Nov 15 2015; edited by M. F. Hasler, Jul 16 2019
    
  • PARI
    rgs_transform(invec) = { my(occurrences = Map(), outvec = vector(length(invec)), u=1); for(i=1, length(invec), if(mapisdefined(occurrences,invec[i]), my(pp = mapget(occurrences, invec[i])); outvec[i] = outvec[pp] , mapput(occurrences,invec[i],i); outvec[i] = u; u++ )); outvec; };
    write_to_bfile(start_offset,vec,bfilename) = { for(n=1, length(vec), write(bfilename, (n+start_offset)-1, " ", vec[n])); }
    write_to_bfile(1,rgs_transform(vector(100000,n,A046523(n))),"b101296.txt");
    \\ Antti Karttunen, May 12 2017

Formula

A025487(a(n)) = A046523(n).
Indices of records give A025487. - Michel Marcus, Nov 16 2015
From David A. Corneth, May 12 2017: (Start) [Corresponding characteristic function in brackets]
a(A000012(n)) = 1 (sig.: ()). [A063524]
a(A000040(n)) = 2 (sig.: (1)). [A010051]
a(A001248(n)) = 3 (sig.: (2)). [A302048]
a(A006881(n)) = 4 (sig.: (1,1)). [A280710]
a(A030078(n)) = 5 (sig.: (3)).
a(A054753(n)) = 6 (sig.: (1,2)). [A353472]
a(A030514(n)) = 7 (sig.: (4)).
a(A065036(n)) = 8 (sig.: (1,3)).
a(A007304(n)) = 9 (sig.: (1,1,1)). [A354926]
a(A050997(n)) = 10 (sig.: (5)).
a(A085986(n)) = 11 (sig.: (2,2)).
a(A178739(n)) = 12 (sig.: (1,4)).
a(A085987(n)) = 13 (sig.: (1,1,2)).
a(A030516(n)) = 14 (sig.: (6)).
a(A143610(n)) = 15 (sig.: (2,3)).
a(A178740(n)) = 16 (sig.: (1,5)).
a(A189975(n)) = 17 (sig.: (1,1,3)).
a(A092759(n)) = 18 (sig.: (7)).
a(A189988(n)) = 19 (sig.: (2,4)).
a(A179643(n)) = 20 (sig.: (1,2,2)).
a(A189987(n)) = 21 (sig.: (1,6)).
a(A046386(n)) = 22 (sig.: (1,1,1,1)).
a(A162142(n)) = 23 (sig.: (2,2,2)).
a(A179644(n)) = 24 (sig.: (1,1,4)).
a(A179645(n)) = 25 (sig.: (8)).
a(A179646(n)) = 26 (sig.: (2,5)).
a(A163569(n)) = 27 (sig.: (1,2,3)).
a(A179664(n)) = 28 (sig.: (1,7)).
a(A189982(n)) = 29 (sig.: (1,1,1,2)).
a(A179666(n)) = 30 (sig.: (3,4)).
a(A179667(n)) = 31 (sig.: (1,1,5)).
a(A179665(n)) = 32 (sig.: (9)).
a(A189990(n)) = 33 (sig.: (2,6)).
a(A179669(n)) = 34 (sig.: (1,2,4)).
a(A179668(n)) = 35 (sig.: (1,8)).
a(A179670(n)) = 36 (sig.: (1,1,1,3)).
a(A179671(n)) = 37 (sig.: (3,5)).
a(A162143(n)) = 38 (sig.: (2,2,2)).
a(A179672(n)) = 39 (sig.: (1,1,6)).
a(A030629(n)) = 40 (sig.: (10)).
a(A179688(n)) = 41 (sig.: (1,3,3)).
a(A179689(n)) = 42 (sig.: (2,7)).
a(A179690(n)) = 43 (sig.: (1,1,2,2)).
a(A189991(n)) = 44 (sig.: (4,4)).
a(A179691(n)) = 45 (sig.: (1,2,5)).
a(A179692(n)) = 46 (sig.: (1,9)).
a(A179693(n)) = 47 (sig.: (1,1,1,4)).
a(A179694(n)) = 48 (sig.: (3,6)).
a(A179695(n)) = 49 (sig.: (2,2,3)).
a(A179696(n)) = 50 (sig.: (1,1,7)).
(End)

Extensions

Data section extended to 120 terms by Antti Karttunen, May 12 2017
Minor edits/corrections by M. F. Hasler, Jul 18 2019

A051885 Smallest number whose sum of digits is n.

Original entry on oeis.org

0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 19, 29, 39, 49, 59, 69, 79, 89, 99, 199, 299, 399, 499, 599, 699, 799, 899, 999, 1999, 2999, 3999, 4999, 5999, 6999, 7999, 8999, 9999, 19999, 29999, 39999, 49999, 59999, 69999, 79999, 89999, 99999, 199999, 299999, 399999, 499999
Offset: 0

Views

Author

Felice Russo, Dec 15 1999

Keywords

Comments

This is also the list of lunar triangular numbers: A087052 with duplicates removed. - N. J. A. Sloane, Jan 25 2011
Numbers n such that A061486(n) = n. - Amarnath Murthy, May 06 2001
The product of digits incremented by 1 is the same as the number incremented by 1. If a(n) = abcd...(a,b,c,d, etc. are digits of a(n)) {a(n) + 1} = (a+1)*(b+1)(c+1)*(d+1)*..., e.g., 299 + 1 = (2+1)*(9+1)*(9+1) = 300. - Amarnath Murthy, Jul 29 2003
A138471(a(n)) = 0. - Reinhard Zumkeller, Mar 19 2008
a(n+1) = A108971(A179988(n)). - Reinhard Zumkeller, Aug 09 2010, Jul 10 2011
Positions of records in A003132: A080151(n) = A003132(a(n)). - Reinhard Zumkeller, Jul 10 2011
a(n) = A242614(n,1). - Reinhard Zumkeller, Jul 16 2014
A254524(a(n)) = 1. - Reinhard Zumkeller, Oct 09 2015
The slowest strictly increasing sequence of nonnegative integers such that, for any two terms, calculating the difference of their decimal representations requires no borrowing. - Rick L. Shepherd, Aug 11 2017

Crossrefs

Numbers of form i*b^j-1 (i=1..b-1, j >= 0) for bases b = 2 through 9: A000225, A062318, A180516, A181287, A181288, A181303, A165804, A140576. - N. J. A. Sloane, Jan 25 2011
Cf. A002283.
Cf. A254524.

Programs

  • Haskell
    a051885 n = (m + 1) * 10^n' - 1 where (n',m) = divMod n 9
    -- Reinhard Zumkeller, Jul 10 2011
    
  • Magma
    [i*10^j-1: i in [1..9], j in [0..5]];
    
  • Maple
    b:=10; t1:=[]; for j from 0 to 15 do for i from 1 to b-1 do t1:=[op(t1), i*b^j-1]; od: od: t1; # N. J. A. Sloane, Jan 25 2011
  • Mathematica
    a[n_] := (Mod[n, 9] + 1)*10^Floor[n/9] - 1; Table[a[n], {n, 0, 49}](* Jean-François Alcover, Dec 01 2011, after Henry Bottomley *)
  • PARI
    A051885(n) = (n%9+1)*10^(n\9)-1  \\ M. F. Hasler, Jun 17 2012
    
  • PARI
    first(n) = Vec(x*(x^2 + x + 1)*(x^6 + x^3 + 1)/((x - 1)*(10*x^9 - 1)) + O(x^n), -n) \\ Iain Fox, Dec 30 2017
    
  • Python
    def A051885(n): return ((n % 9)+1)*10**(n//9)-1 # Chai Wah Wu, Apr 04 2021

Formula

These are the numbers i*10^j-1 (i=1..9, j >= 0). - N. J. A. Sloane, Jan 25 2011
a(n) = ((n mod 9) + 1)*10^floor(n/9) - 1 = a(n-1) + 10^floor((n-1)/9). - Henry Bottomley, Apr 24 2001
a(n) = A037124(n+1) - 1. - Reinhard Zumkeller, Jan 03 2008, Jul 10 2011
G.f.: x*(x^2+x+1)*(x^6+x^3+1) / ((x-1)*(10*x^9-1)). - Colin Barker, Feb 01 2013

Extensions

More terms from James Sellers, Dec 16 1999
Offset fixed by Reinhard Zumkeller, Jul 10 2011

A052224 Numbers whose sum of digits is 10.

Original entry on oeis.org

19, 28, 37, 46, 55, 64, 73, 82, 91, 109, 118, 127, 136, 145, 154, 163, 172, 181, 190, 208, 217, 226, 235, 244, 253, 262, 271, 280, 307, 316, 325, 334, 343, 352, 361, 370, 406, 415, 424, 433, 442, 451, 460, 505, 514, 523, 532, 541, 550, 604, 613, 622, 631, 640
Offset: 1

Views

Author

Henry Bottomley, Feb 01 2000

Keywords

Comments

Proper subsequence of A017173. - Rick L. Shepherd, Jan 12 2009
Subsequence of A227793. - Michel Marcus, Sep 23 2013
A007953(a(n)) = 10; number of repdigits = #{55,22222,1^10} = A242627(10) = 3. - Reinhard Zumkeller, Jul 17 2014
a(n) = A094677(n) for n = 1..28. - Reinhard Zumkeller, Nov 08 2015
The number of terms having <= m digits is the coefficient of x^10 in sum(i=0,9,x^i)^m = ((1-x^10)/(1-x))^m. - David A. Corneth, Jun 04 2016
In general, the set of numbers with sum of base-b digits equal to b is a subset of { (b-1)*k + 1; k = 2, 3, 4, ... }. - M. F. Hasler, Dec 23 2016

Crossrefs

Cf. A011557 (1), A052216 (2), A052217 (3), A052218 (4), A052219 (5), A052220 (6), A052221 (7), A052222 (8), A052223 (9), A166311 (11), A235151 (12), A143164 (13), A235225 (14), A235226 (15), A235227 (16), A166370 (17), A235228 (18), A166459 (19), A235229 (20).
Cf. A094677.
Sum of base-b digits equal b: A226636 (b = 3), A226969 (b = 4), A227062 (b = 5), A227080 (b = 6), A227092 (b = 7), A227095 (b = 8), A227238 (b = 9).

Programs

  • Haskell
    a052224 n = a052224_list !! (n-1)
    a052224_list = filter ((== 10) . a007953) [0..]
    -- Reinhard Zumkeller, Jul 17 2014
    
  • Magma
    [n: n in [1..1000] | &+Intseq(n) eq 10 ]; // Vincenzo Librandi, Mar 10 2013
    
  • Maple
    sd := proc (n) options operator, arrow: add(convert(n, base, 10)[j], j = 1 .. nops(convert(n, base, 10))) end proc: a := proc (n) if sd(n) = 10 then n else end if end proc: seq(a(n), n = 1 .. 800); # Emeric Deutsch, Jan 16 2009
  • Mathematica
    Union[Flatten[Table[FromDigits /@ Permutations[PadRight[s, 7]], {s, Rest[IntegerPartitions[10]]}]]] (* T. D. Noe, Mar 08 2013 *)
    Select[Range[1000], Total[IntegerDigits[#]] == 10 &] (* Vincenzo Librandi, Mar 10 2013 *)
  • PARI
    isok(n) = sumdigits(n) == 10; \\ Michel Marcus, Dec 28 2015
    
  • PARI
    \\ This algorithm needs a modified binomial.
    C(n, k)=if(n>=k, binomial(n, k), 0)
    \\ ways to roll s-q with q dice having sides 0 through n - 1.
    b(s, q, n)=if(s<=q*(n-1), s+=q; sum(i=0, q-1, (-1)^i*C(q, i)*C(s-1-n*i, q-1)), 0)
    \\ main algorithm; this program applies to all sequences of the form "Numbers whose sum of digits is m."
    a(n,{m=10}) = {my(q); q = 2; while(b(m, q, 10) < n, q++); q--; s = m; os = m; r=0; while(q, if(b(s, q, 10) < n, n-=b(s, q, 10); s--, r+=(os-s)*10^(q); os = s; q--)); r+= s; r}
    \\ David A. Corneth, Jun 05 2016
    
  • Python
    from sympy.utilities.iterables import multiset_permutations
    def auptodigs(maxdigits, b=10, sod=10): # works for any base, sum-of-digits
        alst = [sod] if 0 <= sod < b else []
        nzdigs = [i for i in range(1, b) if i <= sod]
        nzmultiset = []
        for d in range(1, b):
            nzmultiset += [d]*(sod//d)
        for d in range(2, maxdigits + 1):
            fullmultiset = [0]*(d-1-(sod-1)//(b-1)) + nzmultiset
            for firstdig in nzdigs:
                target_sum, restmultiset = sod - int(firstdig), fullmultiset[:]
                restmultiset.remove(firstdig)
                for p in multiset_permutations(restmultiset, d-1):
                  if sum(p) == target_sum:
                      alst.append(int("".join(map(str, [firstdig]+p)), b))
                      if p[0] == target_sum:
                          break
        return alst
    print(auptodigs(4)) # Michael S. Branicky, Sep 14 2021
    
  • Python
    def A052224(N = 19):
        """Return a generator of the sequence of all integers >= N with the same
        digit sum as N."""
        while True:
            yield N
            N = A228915(N) # skip to next larger integer with the same digit sum
    a = A052224(); [next(a) for  in range(50)] # _M. F. Hasler, Mar 16 2022

Formula

a(n+1) = A228915(a(n)) for any n > 0. - Rémy Sigrist, Jul 10 2018

Extensions

Incorrect formula deleted by N. J. A. Sloane, Jan 15 2009
Extended by Emeric Deutsch, Jan 16 2009
Offset changed by Bruno Berselli, Mar 07 2013

A317086 Number of normal integer partitions of n whose sequence of multiplicities is a palindrome.

Original entry on oeis.org

1, 1, 1, 2, 1, 1, 3, 1, 2, 2, 4, 1, 4, 1, 4, 5, 4, 1, 7, 1, 8, 6, 6, 1, 10, 5, 7, 8, 11, 1, 20, 1, 9, 12, 9, 13, 25, 1, 10, 17, 21, 1, 37, 1, 21, 36, 12, 1, 44, 16, 23, 30, 33, 1, 53, 17, 55, 38, 15, 1, 103, 1, 16, 95, 51, 28, 69, 1, 73, 57, 82
Offset: 0

Views

Author

Gus Wiseman, Jul 21 2018

Keywords

Comments

A partition is normal if its parts span an initial interval of positive integers.
a(n) = 1 if and only if n = 0, 1, 2, 4 or a prime > 3. - Chai Wah Wu, Jun 22 2020
From David A. Corneth, Jul 08 2020: (Start)
Let [f_1, f_2, ,..., f_i, ..., f_m] be the multiplicities of parts i in a partition of Sum_{i=1..m} (f_i * i). Then, as the sequence of multiplicities is a palindrome, we have f_1 = f_m, ..., f_i = f_(m+1-i). So the sum is f_1 * (1 + m) + f_2 * (2 + m-1) + ... + f_(floor(m/2)) * m/2 (the last term depending on the parity of m.). This way it becomes a list of Diophantine equations for which we look for the number of solutions.
For example, for m = 4 we look for solutions to the Diophantine equation 5 * (c + d) = n where c, d are positive integers >= 1. A similar technique is used in A254524. (End)

Examples

			The a(20) = 8 partitions:
  (44432111), (44332211), (43332221),
  (3333221111), (3332222111), (3322222211), (3222222221),
  (11111111111111111111).
		

Crossrefs

Programs

  • Mathematica
    Table[Length[Select[IntegerPartitions[n],And[Union[#]==Range[First[#]],Length/@Split[#]==Reverse[Length/@Split[#]]]&]],{n,30}]
  • Python
    from sympy.utilities.iterables import partitions
    from sympy import integer_nthroot, isprime
    def A317086(n):
        if n > 3 and isprime(n):
            return 1
        else:
            c = 1
            for d in partitions(n,k=integer_nthroot(2*n,2)[0],m=n*2//3):
                l = len(d)
                if l > 0:
                    k = max(d)
                    if l == k:
                        for i in range(k//2):
                            if d[i+1] != d[k-i]:
                                break
                        else:
                            c += 1
            return c # Chai Wah Wu, Jun 22 2020

A263017 n is the a(n)-th positive integer having its binary weight.

Original entry on oeis.org

1, 2, 1, 3, 2, 3, 1, 4, 4, 5, 2, 6, 3, 4, 1, 5, 7, 8, 5, 9, 6, 7, 2, 10, 8, 9, 3, 10, 4, 5, 1, 6, 11, 12, 11, 13, 12, 13, 6, 14, 14, 15, 7, 16, 8, 9, 2, 15, 17, 18, 10, 19, 11, 12, 3, 20, 13, 14, 4, 15, 5, 6, 1, 7, 16, 17, 21, 18, 22, 23, 16, 19, 24, 25, 17
Offset: 1

Views

Author

Paul Tek, Oct 07 2015

Keywords

Comments

Binary weight is given by A000120.
a(2^k) = k+1 for any k>=0.
a(2^k-1) = 1 for any k>0.
a(A057168(k)) = a(k)+1 for any k>0.
a(A036563(k+1)) = k for any k>0.
Ordinal transform of A000120. - Alois P. Heinz, Dec 23 2018

Examples

			The numbers with binary weight 3 are: 7, 11, 13, 14, 19, ...
Hence: a(7)=1, a(11)=2, a(13)=3, a(14)=4, a(19)=5, ...
And more generally: a(A014311(k))=k for any k>0.
		

Crossrefs

Programs

  • Haskell
    import Data.IntMap (empty, findWithDefault, insert)
    a263017 n = a263017_list !! (n-1)
    a263017_list = f 1 empty where
       f x m = y : f (x + 1) (insert h (y + 1) m) where
               y = findWithDefault 1 h m
               h = a000120 x
    -- Reinhard Zumkeller, Oct 09 2015
    
  • Maple
    a:= proc() option remember; local a, b, t; b, a:=
          proc() 0 end, proc(n) option remember; a(n-1);
            t:= add(i, i=convert(n, base, 2)); b(t):= b(t)+1
          end; a(0):=0; a
        end():
    seq(a(n), n=1..120);  # Alois P. Heinz, Dec 23 2018
  • Perl
    # See Links section.
    
  • Python
    from math import comb
    def A263017(n):
        c, k = 1, 0
        for i,j in enumerate(bin(n)[-1:1:-1]):
            if j == '1':
                k += 1
                c += comb(i,k)
        return c # Chai Wah Wu, Mar 01 2023

Formula

a(n) = 1 + A068076(n). - Antti Karttunen, May 22 2017

A074784 a(n) = a(n-1) + square of the sum of digits of n.

Original entry on oeis.org

0, 1, 5, 14, 30, 55, 91, 140, 204, 285, 286, 290, 299, 315, 340, 376, 425, 489, 570, 670, 674, 683, 699, 724, 760, 809, 873, 954, 1054, 1175, 1184, 1200, 1225, 1261, 1310, 1374, 1455, 1555, 1676, 1820, 1836, 1861, 1897, 1946, 2010, 2091, 2191, 2312, 2456
Offset: 0

Views

Author

Antonio G. Astudillo (afg_astudillo(AT)hotmail.com), Sep 07 2002

Keywords

Comments

a(n) = Sum_{i=0..n} digsum(i)^2, where digsum(i) = A007953(i). - N. J. A. Sloane, Nov 13 2013

Crossrefs

Partial sums of A118881.

Programs

  • Magma
    [n eq 1 select n else Self(n-1)+(&+Intseq(n))^2: n in [1..48]];  // Bruno Berselli, Jul 12 2011
  • Maple
    See A037123.
  • Mathematica
    Accumulate @ Array[(Plus @@ IntegerDigits[#])^2 &, 50] (* Amiram Eldar, Jan 20 2022 *)

Formula

a(n) = Sum_{k=1..n} s(k)^2 = Sum_{k=1..n} A007953(k)^2, where s(k) denotes the sum of the digits of k in decimal representation.
Asymptotic expression: a(n-1) = Sum_{k=1..n-1} s(k)^2 = 20.25*n*log_10(n)^2 + O(n*log_10(n)).
In general: Sum_{k=1..n-1} s(k)^m = n*((9/2)*log_10(n))^m + O(n*log_10(n)^(m-1)).

Extensions

Offset changed to 0 and a(0) prepended by Amiram Eldar, Jan 20 2022

A263109 n is the a(n)-th positive integer having its digitsum in base-12 representation.

Original entry on oeis.org

1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 2, 1, 4, 4, 4, 4, 4, 4, 4, 4, 4, 3, 2, 1, 5, 5, 5, 5, 5, 5, 5, 5, 4, 3, 2, 1, 6, 6, 6, 6, 6, 6, 6, 5, 4, 3, 2, 1, 7, 7, 7, 7, 7, 7, 6, 5, 4, 3, 2, 1, 8, 8, 8
Offset: 1

Views

Author

Reinhard Zumkeller, Oct 09 2015

Keywords

Comments

Ordinal transform of A053832. - Alois P. Heinz, Dec 23 2018

Crossrefs

Programs

  • Haskell
    import Data.IntMap (empty, findWithDefault, insert)
    a263109 n = a263109_list !! (n-1)
    a263109_list = f 1 empty where
       f x m = y : f (x + 1) (insert q (y + 1) m) where
               y = findWithDefault 1 q m; q = a053832 x
  • Mathematica
    b[_] = 1;
    a[n_] := a[n] = With[{t = Total[IntegerDigits[n, 12]]}, b[t]++];
    Array[a, 100] (* Jean-François Alcover, Dec 18 2021 *)

A263110 n is the a(n)-th positive integer having its digitsum in base-16 representation.

Original entry on oeis.org

1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 2, 1, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 3, 2, 1, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 4, 3, 2, 1, 6, 6, 6, 6, 6, 6, 6
Offset: 1

Views

Author

Reinhard Zumkeller, Oct 09 2015

Keywords

Comments

Ordinal transform of A053836. - Alois P. Heinz, Dec 23 2018

Crossrefs

Programs

  • Haskell
    import Data.IntMap (empty, findWithDefault, insert)
    a263110 n = a263110_list !! (n-1)
    a263110_list = f 1 empty where
       f x m = y : f (x + 1) (insert q (y + 1) m) where
               y = findWithDefault 1 q m; q = a053836 x

A286478 Ordinal transform of A034968, factorial base digit sum.

Original entry on oeis.org

1, 1, 2, 1, 2, 1, 3, 3, 4, 2, 3, 1, 5, 4, 5, 2, 3, 1, 6, 4, 5, 2, 3, 1, 4, 6, 7, 7, 8, 6, 8, 9, 10, 7, 8, 4, 11, 9, 10, 5, 6, 2, 11, 7, 8, 3, 4, 1, 9, 12, 13, 12, 13, 9, 14, 14, 15, 10, 11, 5, 16, 12, 13, 6, 7, 2, 14, 8, 9, 3, 4, 1, 15, 17, 18, 15, 16, 10, 19, 17, 18, 11, 12, 5, 19, 13, 14, 6, 7, 2, 15, 8, 9, 3, 4, 1, 20, 20, 21, 16, 17, 10, 22, 18, 19, 11, 12
Offset: 0

Views

Author

Antti Karttunen, May 20 2017

Keywords

Crossrefs

Cf. A000142, A034968, A254524 (base-10 analog).

Programs

  • Mathematica
    f[n_] := If[n == 0, 0, Module[{s = 0, i = 2, k = n},
         While[k>0, k = Floor[n/i!]; s += (i-1) k; i++]; n-s]];
    b[_] = 1;
    a[n_] := a[n] = With[{t = f[n]}, b[t]++];
    a /@ Range[0, 100] (* Jean-François Alcover, Dec 19 2021 *)

Formula

For all n>= 1, a(A000142(n)) = n.
Showing 1-10 of 18 results. Next