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 13 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

A061383 Arithmetic mean of digits is an integer.

Original entry on oeis.org

0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 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, 102, 105, 108, 111, 114, 117, 120, 123, 126, 129
Offset: 0

Views

Author

Amarnath Murthy, May 03 2001

Keywords

Comments

A004426(a(n)) = A004427(a(n)). - Reinhard Zumkeller, May 27 2010
A175688 is a subsequence; complement of A180157; A180160(a(n))=0. - Reinhard Zumkeller, Aug 15 2010
It seems "obvious" that n log n << a(n) < n log n; is this true? - Charles R Greathouse IV, Feb 06 2013

Examples

			123 is a term as the arithmetic mean is (1+2+3)/3 = 2.
		

Crossrefs

Programs

  • Haskell
    a061383 n = a061383_list !! (n-1)
    a061383_list = filter (\x -> mod (a007953 x) (a055642 x) == 0) [0..]
    -- Reinhard Zumkeller, Jun 18 2013
    
  • Magma
    [0] cat [n: n in [1..130] | IsZero(&+Intseq(n) mod #Intseq(n))];  // Bruno Berselli, Jun 30 2011
    
  • Magma
    [0] cat [n: n in [1..130] | IsIntegral(&+Intseq(n)/#Intseq(n))];   // Bruno Berselli, Feb 09 2016
    
  • Mathematica
    Select[Range[0,129],IntegerQ[Total[x=IntegerDigits[#]]/Length[x]] &] (* Jayanta Basu, May 17 2013 *)
    Select[Range[0,200],IntegerQ[Mean[IntegerDigits[#]]]&] (* Harvey P. Dale, Dec 31 2022 *)
  • PARI
    is(n)=my(v=digits(n));sum(i=1,#v,v[i])%#v==0 \\ Charles R Greathouse IV, Feb 06 2013
    
  • Python
    def ok(n): return n == 0 or sum(d:=list(map(int, str(n))))%len(d) == 0
    print([k for k in range(130) if ok(k)]) # Michael S. Branicky, Apr 23 2025

A004427 Arithmetic mean of digits of n (rounded up).

Original entry on oeis.org

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

Views

Author

Keywords

Comments

a(100)=1 is the first value that differs from the variant "... rounded to the nearest integer". - M. F. Hasler, May 10 2015

Crossrefs

Programs

  • Mathematica
    Ceiling[Mean[IntegerDigits[#]]]&/@Range[0,110] (* Harvey P. Dale, Aug 29 2014 *)
  • PARI
    A004427(n)=ceil(sum(i=1, #n=digits(n), n[i])/#n) \\ ...Vecsmall(Str(n))...-48 is a little faster. \\ M. F. Hasler, May 10 2015

Formula

From Reinhard Zumkeller, May 27 2010: (Start)
a(n) = ceiling(A007953(n)/A055642(n)); a(A000040(n)) = A074462(n);
A004426(n) <= a(n) with equality for n in A061383;
a(A178361(n)) = 1; a(A178362(n)) = 2; a(A178363(n)) = 3; a(A178364(n)) = 4; a(A178365(n)) = 5; a(A178366(n)) = 6; a(A178367(n)) = 7; a(A178368(n)) = 8; a(A178369(n)) = 9. (End)

A052018 Numbers k with the property that the sum of the digits of k is a substring of k.

Original entry on oeis.org

0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 109, 119, 129, 139, 149, 159, 169, 179, 189, 199, 200, 300, 400, 500, 600, 700, 800, 900, 910, 911, 912, 913, 914, 915, 916, 917, 918, 919, 1000, 1009, 1018, 1027, 1036, 1045, 1054, 1063
Offset: 1

Views

Author

Patrick De Geest, Nov 15 1999

Keywords

Crossrefs

Programs

  • Haskell
    import Data.List (isInfixOf)
    a052018 n = a052018_list !! (n-1)
    a052018_list = filter f [0..] where
       f x = show (a007953 x) `isInfixOf` show x
    -- Reinhard Zumkeller, Jun 18 2013
    
  • Mathematica
    sdssQ[n_]:=Module[{idn=IntegerDigits[n],s,len},s=Total[idn];len= IntegerLength[ s]; MemberQ[Partition[idn,len,1],IntegerDigits[s]]]; Join[{0},Select[Range[1100],sdssQ]] (* Harvey P. Dale, Jan 02 2013 *)
  • Python
    loop = (str(n) for n in range(399))
    print([int(n) for n in loop if str(sum(int(k) for k in n)) in n]) # Jonathan Frech, Jun 05 2017

A371383 a(n) is the numerator of the arithmetic mean of the digits of n.

Original entry on oeis.org

0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 1, 3, 2, 5, 3, 7, 4, 9, 5, 1, 3, 2, 5, 3, 7, 4, 9, 5, 11, 3, 2, 5, 3, 7, 4, 9, 5, 11, 6, 2, 5, 3, 7, 4, 9, 5, 11, 6, 13, 5, 3, 7, 4, 9, 5, 11, 6, 13, 7, 3, 7, 4, 9, 5, 11, 6, 13, 7, 15, 7, 4, 9, 5, 11, 6, 13, 7, 15, 8, 4, 9, 5, 11, 6
Offset: 0

Views

Author

Stefano Spezia, Mar 20 2024

Keywords

Crossrefs

Cf. A004426, A004427, A007953, A055642, A061383, A371384 (denominator).

Programs

  • Mathematica
    a[n_]:=Numerator[Mean[IntegerDigits[n]]]; Array[a,85,0]
  • Python
    from math import gcd
    def A371383(n): return (l:=sum(map(int,(s:=str(n)))))//gcd(l,len(s)) # Chai Wah Wu, Mar 22 2024

A371384 a(n) is the denominator of the arithmetic mean of the digits of n.

Original entry on oeis.org

1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2
Offset: 0

Views

Author

Stefano Spezia, Mar 20 2024

Keywords

Crossrefs

Programs

  • Mathematica
    a[n_]:=Denominator[Mean[IntegerDigits[n]]]; Array[a,90,0]
  • Python
    from math import gcd
    def A371384(n): return (l:=len(s:=str(n)))//gcd(l,sum(map(int,s))) # Chai Wah Wu, Mar 22 2024

A175688 Numbers k with property that arithmetic mean of its digits is both an integer and one of the digits of k.

Original entry on oeis.org

0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 11, 22, 33, 44, 55, 66, 77, 88, 99, 102, 111, 120, 123, 132, 135, 147, 153, 159, 174, 195, 201, 204, 210, 213, 222, 231, 234, 240, 243, 246, 258, 264, 285, 306, 312, 315, 321, 324, 333, 342, 345, 351, 354, 357, 360, 369, 375, 396, 402
Offset: 1

Views

Author

Claudio Meller, Aug 09 2010

Keywords

Comments

Subsequence of A061383.
A180160(a(n)) = 0. - Reinhard Zumkeller, Aug 15 2010

Examples

			135 is in the list because (1+3+5)/3 = 3 and 3 is a digit of 135.
		

Crossrefs

Programs

  • Haskell
    a175688 n = a175688_list !! (n-1)
    a175688_list = filter f [0..] where
       f x = m == 0 && ("0123456789" !! avg) `elem` show x
             where (avg, m) = divMod (a007953 x) (a055642 x)
    -- Reinhard Zumkeller, Jun 18 2013
  • Mathematica
    idQ[n_]:=Module[{idn=IntegerDigits[n],m},m=Mean[idn];IntegerQ[m] && MemberQ[idn,m]]; Select[Range[0,500],idQ] (* Harvey P. Dale, Jun 10 2011 *)

Extensions

Edited by Reinhard Zumkeller, Aug 13 2010

A074461 Average digit (rounded down) in the decimal expansion of the n-th prime number.

Original entry on oeis.org

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

Views

Author

Y. Kelly Itakura (yitkr(AT)mta.ca), Aug 23 2002

Keywords

Examples

			prime numbers: 2, 3, 5, 7, 11, 13, 17, 19, 23, ... so the average digits rounded down are; 2, 3, 5, 7, (1+1)/2 = 1, (1+3)/2 = 2, (1+7)/2 = 4, (1+9)/2 = 5, floor((2+3)/2) = 2, ...
		

Crossrefs

Programs

  • PARI
    a(n)={my(v=digits(prime(n))); vecsum(v)\#v} \\ Andrew Howroyd, Jan 16 2020

Formula

a(n) = A004426(A000040(n)). - Reinhard Zumkeller, May 27 2010

Extensions

Offset corrected and terms a(21) and beyond from Andrew Howroyd, Jan 16 2020

A180157 Arithmetic mean of digits is not an integer.

Original entry on oeis.org

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, 101, 103, 104, 106, 107, 109, 110, 112, 113, 115, 116, 118, 119, 121, 122, 124, 125
Offset: 1

Views

Author

Reinhard Zumkeller, Aug 15 2010

Keywords

Comments

Complement of A061383; A180160(a(n)) > 0;
A004426(a(n)) <> A004427(a(n)).
It seems 'obvious' that a(n) ~ n; is this true? - Charles R Greathouse IV, Feb 06 2013

Crossrefs

Programs

  • Mathematica
    Select[Range[200],!IntegerQ[Mean[IntegerDigits[#]]]&]  (* Harvey P. Dale, Mar 27 2011 *)
  • PARI
    is(n)=my(v=digits(n));sum(i=1,#v,v[i])%#v>0 \\ Charles R Greathouse IV, Feb 06 2013

A257295 Arithmetic mean of the digits of n, rounded to the nearest integer.

Original entry on oeis.org

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

Views

Author

M. F. Hasler, May 10 2015

Keywords

Comments

Coincides up to a(99) with the variant A004427 (= arithmetic mean of digits, rounded up). - M. F. Hasler, May 10 2015
0 <= a(n) <= 9. a(10*n + a(n)) = a(n). - Robert Israel, May 11 2015

Crossrefs

Programs

  • Maple
    f:= proc(n) local L;
       L:= convert(n,base,10);
       round(convert(L,`+`)/nops(L))
    end proc:
    map(f, [$0..100]); # Robert Israel, May 11 2015
  • Mathematica
    Round[Mean[IntegerDigits[#]]]&/@Range[0,110]
  • PARI
    A257295(n)=round(sum(i=1, #n=digits(n), n[i])/#n) \\ ...Vecsmall(Str(n))...-48 is a little faster.
    
  • PARI
    a(n)=round(sumdigits(n)/#digits(n)) \\ Charles R Greathouse IV, May 11 2015

Formula

a(n) = round(A007953(n)/A055642(n)).
A004426(n) <= a(n) <= A004427(n).
Showing 1-10 of 13 results. Next