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 10 results.

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

A054683 Numbers whose sum of digits is even.

Original entry on oeis.org

0, 2, 4, 6, 8, 11, 13, 15, 17, 19, 20, 22, 24, 26, 28, 31, 33, 35, 37, 39, 40, 42, 44, 46, 48, 51, 53, 55, 57, 59, 60, 62, 64, 66, 68, 71, 73, 75, 77, 79, 80, 82, 84, 86, 88, 91, 93, 95, 97, 99, 101, 103, 105, 107, 109, 110, 112, 114, 116, 118, 121, 123, 125, 127, 129, 130
Offset: 1

Views

Author

Odimar Fabeny, Apr 19 2000

Keywords

Comments

Union of A179082 and A179084; A179081(a(n)) = 0. - Reinhard Zumkeller, Jun 28 2010
Integers with an even number of odd digits. - Bernard Schott, Nov 18 2022

Examples

			0, 2, 4, 6, 8, 11 (2), 13 (4), 15 (6), 17 (8), 19 (10), 20 (2), 22 (4) and so on.
		

Crossrefs

Subsequences: A014263, A099814, A179082, A179084.
Similar: A054684 (with an odd number of odd digits), A356929 (with an even number of even digits).

Programs

  • Mathematica
    Select[Range[0,200],EvenQ[Total[IntegerDigits[#]]]&] (* Harvey P. Dale, Jan 04 2015 *)
  • PARI
    is(n)=my(d=digits(n));sum(i=1,#d,d[i])%2==0 \\ Charles R Greathouse IV, Aug 09 2013
    
  • PARI
    a(n) = n--; m = 10*(n\5); s=sumdigits(m); m + (1-(s-1)%2) + 2*(n%5) \\ David A. Corneth, Jun 05 2016
    
  • Python
    A054683_list = [i for i in range(10**3) if not sum(int(d) for d in str(i)) % 2] # Chai Wah Wu, Mar 17 2016

Formula

a(n) = 2*n for the first 5 terms; a(n) = 2*n + 1 for the next 5 terms (recurrence).
I.e., for n > 0, a(n + 10) = a(n) + 20. - David A. Corneth, Jun 05 2016

Extensions

More terms from James Sellers, Apr 19 2000
Example corrected by David A. Corneth, Jun 05 2016

A054684 Numbers whose sum of digits is odd.

Original entry on oeis.org

1, 3, 5, 7, 9, 10, 12, 14, 16, 18, 21, 23, 25, 27, 29, 30, 32, 34, 36, 38, 41, 43, 45, 47, 49, 50, 52, 54, 56, 58, 61, 63, 65, 67, 69, 70, 72, 74, 76, 78, 81, 83, 85, 87, 89, 90, 92, 94, 96, 98, 100, 102, 104, 106, 108, 111, 113, 115, 117, 119, 120, 122, 124, 126, 128, 131
Offset: 1

Views

Author

Odimar Fabeny, Apr 19 2000

Keywords

Comments

Union of A179083 and A179085; A179081(a(n)) = 1. - Reinhard Zumkeller, Jun 28 2010
Equivalently, integers with an odd number of odd digits. - Bernard Schott, Nov 06 2022

Examples

			1, 3, 5, 7, 9, 10(1), 12(3), 14(5), 16(7), 18(9), 21(3) and so on.
		

Crossrefs

Cf. A054683, A137233 (number of n-digits terms).
Cf. A356929 (even number of even digits).
A294601 (exactly one odd decimal digit) is a subsequence.

Programs

  • Maple
    [seq(`if`(convert(convert(2*n-1,base,10),`+`)::odd, 2*n-1, 2*n-2), n=1..501)];
  • Mathematica
    Select[Range[200],OddQ[Total[IntegerDigits[#]]]&] (* Harvey P. Dale, Nov 27 2021 *)
  • PARI
    is(n)=my(d=digits(n));sum(i=1,#d,d[i])%2 \\ Charles R Greathouse IV, Aug 09 2013
    
  • PARI
    isok(m) = sumdigits(m) % 2; \\ Michel Marcus, Nov 06 2022
    
  • PARI
    a(n) = n=2*(n-1); n + !(sumdigits(n)%2); \\ Kevin Ryde, Nov 07 2022
    
  • Python
    def ok(n): return sum(map(int, str(n)))&1
    print([k for k in range(132) if ok(k)]) # Michael S. Branicky, Nov 06 2022

Formula

a(n) = n * 2 - 1 for the first 5 numbers; a(n) = n * 2 for the second 5 numbers.
From Robert Israel, Jun 27 2017: (Start)
a(n) = 2*n-2 if floor((n-1)/5) is in the sequence, 2*n-1 if not.
G.f. g(x) satisfies g(x) = (1-x)*(1+x+x^2+x^3+x^4)^2*g(x^10)/x^9 + x^2*(2+x^4+3*x^5-x^9+3*x^10)/((1-x)*(1+x^5))^2.
(End)

Extensions

More terms from James Sellers, Apr 19 2000

A179082 Even numbers having an even sum of digits in their decimal representation.

Original entry on oeis.org

0, 2, 4, 6, 8, 20, 22, 24, 26, 28, 40, 42, 44, 46, 48, 60, 62, 64, 66, 68, 80, 82, 84, 86, 88, 110, 112, 114, 116, 118, 130, 132, 134, 136, 138, 150, 152, 154, 156, 158, 170, 172, 174, 176, 178, 190, 192, 194, 196, 198, 200, 202, 204, 206, 208, 220, 222, 224, 226
Offset: 1

Views

Author

Reinhard Zumkeller, Jun 28 2010

Keywords

Comments

a(n) = A014263(n) for n <= 25;
intersection of A005843 and A054683: A059841(a(n))*(1-A179081(a(n)))=1;
complement of A179083 with respect to A005843;
complement of A179084 with respect to A054683;
a(n) mod 2 = 0 and A007953(a(n)) mod 2 = 0.

Programs

  • Mathematica
    Select[Range[0,250,2],EvenQ[Total[IntegerDigits[#]]]&] (* Harvey P. Dale, Mar 19 2012 *)

A179085 Odd numbers having an odd sum of digits in their decimal representation.

Original entry on oeis.org

1, 3, 5, 7, 9, 21, 23, 25, 27, 29, 41, 43, 45, 47, 49, 61, 63, 65, 67, 69, 81, 83, 85, 87, 89, 111, 113, 115, 117, 119, 131, 133, 135, 137, 139, 151, 153, 155, 157, 159, 171, 173, 175, 177, 179, 191, 193, 195, 197, 199, 201, 203, 205, 207, 209, 221, 223, 225, 227
Offset: 1

Views

Author

Reinhard Zumkeller, Jun 28 2010

Keywords

Comments

a(n) = A030142(n) for n <= 25;
intersection of A005408 and A054684: A000035(a(n))*A179081(a(n))=1;
complement of A179084 with respect to A005408;
complement of A179083 with respect to A054684;
a(n) mod 2 = 1 and A007953(a(n)) mod 2 = 1.

Programs

  • Mathematica
    Select[Range[1,227,2], OddQ[Total[IntegerDigits[#]]] &] (* Jayanta Basu, May 07 2013 *)

A179083 Even numbers having an odd sum of digits in their decimal representation.

Original entry on oeis.org

10, 12, 14, 16, 18, 30, 32, 34, 36, 38, 50, 52, 54, 56, 58, 70, 72, 74, 76, 78, 90, 92, 94, 96, 98, 100, 102, 104, 106, 108, 120, 122, 124, 126, 128, 140, 142, 144, 146, 148, 160, 162, 164, 166, 168, 180, 182, 184, 186, 188, 210, 212, 214, 216, 218, 230, 232, 234
Offset: 1

Views

Author

Reinhard Zumkeller, Jun 28 2010

Keywords

Comments

a(n) = A007958(n) for n <= 30;
intersection of A005843 and A054684: A059841(a(n))*A179081(a(n))=1;
complement of A179082 with respect to A005843;
complement of A179085 with respect to A054684;
a(n) mod 2 = 0 and A007953(a(n)) mod 2 = 1.

A179084 Odd numbers having an even sum of digits in their decimal representation.

Original entry on oeis.org

11, 13, 15, 17, 19, 31, 33, 35, 37, 39, 51, 53, 55, 57, 59, 71, 73, 75, 77, 79, 91, 93, 95, 97, 99, 101, 103, 105, 107, 109, 121, 123, 125, 127, 129, 141, 143, 145, 147, 149, 161, 163, 165, 167, 169, 181, 183, 185, 187, 189, 211, 213, 215, 217, 219, 231, 233, 235
Offset: 1

Views

Author

Reinhard Zumkeller, Jun 28 2010

Keywords

Comments

Intersection of A005408 and A054683: A000035(a(n))*(1-A179081(a(n)))=1;
complement of A179085 with respect to A005408;
complement of A179082 with respect to A054683;
a(n) mod 2 = 1 and A007953(a(n)) mod 2 = 0.

A298638 Numbers k such that the digital sum of k and the digital root of k have opposite parity.

Original entry on oeis.org

19, 28, 29, 37, 38, 39, 46, 47, 48, 49, 55, 56, 57, 58, 59, 64, 65, 66, 67, 68, 69, 73, 74, 75, 76, 77, 78, 79, 82, 83, 84, 85, 86, 87, 88, 89, 91, 92, 93, 94, 95, 96, 97, 98, 99, 109, 118, 119, 127, 128, 129, 136, 137, 138, 139, 145, 146, 147, 148, 149, 154, 155
Offset: 1

Views

Author

J. Stauduhar, Jan 23 2018

Keywords

Comments

Numbers k such that A113217(k) <> A179081(k).
Complement of A298639.
Agrees with A291884 until a(46): a(46) = 109 is not in that sequence.

Crossrefs

Programs

  • Mathematica
    Select[Range[145], EvenQ@ Total@ IntegerDigits@ # != EvenQ@ NestWhile[Total@ IntegerDigits@ # &, #, # > 9 &] &] (* Michael De Vlieger, Feb 03 2018 *)
  • PARI
    isok(n) = sumdigits(n) % 2 != if (n, ((n-1)%9+1) % 2, 0); \\ Michel Marcus, Mar 01 2018
  • Python
    #Digital sum of n.
    def ds(n):
      if n < 10:
        return n
      return n % 10 + ds(n//10)
    def A298638(term_count):
      seq = []
      m = 0
      n = 1
      while n <= term_count:
        s = ds(m)
        r = ((m - 1) % 9) + 1 if m else 0
        if s % 2 != r % 2:
          seq.append(m)
          n += 1
        m += 1
      return seq
    print(A298638(100))
    

A298639 Numbers k such that the digital sum of k and the digital root of k have the same parity.

Original entry on oeis.org

0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 20, 21, 22, 23, 24, 25, 26, 27, 30, 31, 32, 33, 34, 35, 36, 40, 41, 42, 43, 44, 45, 50, 51, 52, 53, 54, 60, 61, 62, 63, 70, 71, 72, 80, 81, 90, 100, 101, 102, 103, 104, 105, 106, 107, 108, 110, 111, 112, 113, 114
Offset: 1

Views

Author

J. Stauduhar, Jan 26 2018

Keywords

Comments

Numbers k such that A113217(k) = A179081(k).
Complement of A298638.
Agrees with A039691 until a(65): A039691(65) = 109 is not in this sequence.

Crossrefs

Programs

  • Mathematica
    fQ[n_] := Mod[Plus @@ IntegerDigits@n, 2] == Mod[Mod[n -1, 9] +1, 2]; fQ[0] = True; Select[ Range[0, 104], fQ] (* Robert G. Wilson v, Jan 26 2018 *)
  • PARI
    dr(n)=if(n, (n-1)%9+1);
    isok(n) = (sumdigits(n) % 2) == (dr(n) % 2); \\ Michel Marcus, Jan 26 2018
    
  • PARI
    is(n)=bittest(sumdigits(n)-(n-1)%9,0)||!n \\ M. F. Hasler, Jan 26 2018
  • Python
    #Digital sum of n.
    def ds(n):
      if n < 10:
        return n
      return n % 10 + ds(n//10)
    def A298639(term_count):
      seq = []
      m = 0
      n = 1
      while n <= term_count:
        s = ds(m)
        r = ((m - 1) % 9) + 1 if m else 0
        if s % 2 == r % 2:
          seq.append(m)
          n += 1
        m += 1
      return seq
    print(A298639(100))
    

A358270 Numbers whose sum of digits is even and that have an even number of even digits.

Original entry on oeis.org

11, 13, 15, 17, 19, 20, 22, 24, 26, 28, 31, 33, 35, 37, 39, 40, 42, 44, 46, 48, 51, 53, 55, 57, 59, 60, 62, 64, 66, 68, 71, 73, 75, 77, 79, 80, 82, 84, 86, 88, 91, 93, 95, 97, 99, 1001, 1003, 1005, 1007, 1009, 1010, 1012, 1014, 1016, 1018, 1021, 1023, 1025, 1027, 1029, 1030
Offset: 1

Views

Author

Bernard Schott, Nov 06 2022

Keywords

Comments

There are only terms with an even number of digits, and precisely, there exist A137233(2*k) terms with 2*k digits.
The conditions separately are A054683 for even sum of digits, and A356929 for even number of even digits, so that this sequence is their intersection.
The opposite conditions, an odd sum of digits, and an odd number of odd digits, are the same and are A054684.

Examples

			26 is a term since 2+6 = 8 (even) and 26 has two even digits.
39 is a term since 3+9 = 12 (even) and 39 has zero even digits.
1012 is a term since 1+0+1+2 = 4 (even) and 1012 has two even digits.
		

Crossrefs

Intersection of A054683 and A356929.
Cf. A001637 (even length), A179081 (digit sum mod 2).

Programs

  • Mathematica
    Select[Range[1000], EvenQ[Plus @@ IntegerDigits[#]] && EvenQ[Plus @@ DigitCount[#, 10, Range[0, 8, 2]]] &] (* Amiram Eldar, Nov 06 2022 *)
  • PARI
    a(n) = n*=2; n += 100^logint(110*n,100) \ 11; n - sumdigits(n)%2; \\ Kevin Ryde, Nov 10 2022
  • Python
    def ok(n): s = str(n); return sum(map(int, s))%2 == sum(1 for d in s if d in "02468")%2 == 0
    print([k for k in range(1031) if ok(k)]) # Michael S. Branicky, Nov 06 2022
    
  • Python
    from itertools import count, islice, chain
    def A358270_gen(): # generator of terms
        return filter(lambda n:not (len(s:=str(n))&1 or sum(int(d) for d in s)&1), chain.from_iterable((range(10**l,10**(l+1)) for l in count(1,2))))
    A358270_list = list(islice(A358270_gen(),61)) # Chai Wah Wu, Nov 11 2022
    

Formula

a(n) = t - A179081(t) where t = A001637(2*n). - Kevin Ryde, Nov 10 2022
Showing 1-10 of 10 results.