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

A055014 Sum of 5th powers of digits of n.

Original entry on oeis.org

0, 1, 32, 243, 1024, 3125, 7776, 16807, 32768, 59049, 1, 2, 33, 244, 1025, 3126, 7777, 16808, 32769, 59050, 32, 33, 64, 275, 1056, 3157, 7808, 16839, 32800, 59081, 243, 244, 275, 486, 1267, 3368, 8019, 17050, 33011, 59292, 1024, 1025, 1056, 1267, 2048
Offset: 0

Views

Author

Henry Bottomley, May 31 2000

Keywords

Comments

Fixed points are listed in A052464. - M. F. Hasler, Apr 12 2015

Crossrefs

Programs

  • Magma
    [0] cat [&+[d^5: d in Intseq(n)]: n in [1..45]]; // Bruno Berselli, Feb 01 2013
    
  • Maple
    A055014 := proc(n)
       add(d^5,d=convert(n,base,10)) ;
    end proc: # R. J. Mathar, Jul 08 2012
  • Mathematica
    Total/@(IntegerDigits[Range[50]]^5)  (* Harvey P. Dale, Jan 22 2011 *)
    Table[Sum[DigitCount[n][[i]] i^5, {i, 9}], {n, 0, 45}] (* Bruno Berselli, Feb 01 2013 *)
  • PARI
    A055014(n)=sum(i=1, #n=digits(n), n[i]^5) \\ M. F. Hasler, Apr 12 2015

Formula

a(n) = Sum_{k>=1} (floor(n/10^k) - 10*floor(n/10^(k+1)))^5. - Hieronymus Fischer, Jun 25 2007
a(10n+k) = a(n) + k^5, 0 <= k < 10. - Hieronymus Fischer, Jun 25 2007

A052455 Fixed points for operation of repeatedly replacing a number with the sum of the fourth power of its digits.

Original entry on oeis.org

0, 1, 1634, 8208, 9474
Offset: 1

Views

Author

Henry Bottomley, Mar 15 2000

Keywords

Comments

This is row n=4 in A252648. - M. F. Hasler, Apr 12 2015

Examples

			a(2)=1634 since 1^4+6^4+3^4+4^4=1+1296+81+256=1634
		

Crossrefs

Programs

Formula

a(n) = A055013(a(n)). - M. F. Hasler, Apr 12 2015

A055015 Sum of 6th powers of digits of n.

Original entry on oeis.org

0, 1, 64, 729, 4096, 15625, 46656, 117649, 262144, 531441, 1, 2, 65, 730, 4097, 15626, 46657, 117650, 262145, 531442, 64, 65, 128, 793, 4160, 15689, 46720, 117713, 262208, 531505, 729, 730, 793, 1458, 4825, 16354, 47385, 118378, 262873
Offset: 0

Views

Author

Henry Bottomley, May 31 2000

Keywords

Comments

The only fixed points (n = 0, 1 and 548834) are listed in row 6 of A252648. - M. F. Hasler, Apr 12 2015

Crossrefs

Programs

  • Magma
    [0] cat [&+[d^6: d in Intseq(n)]: n in [1..40]]; // Bruno Berselli, Feb 01 2013
    
  • Maple
    for n from 0 to 3 do seq(n^6+j^6, j=0..9 ); od; # Zerinvary Lajos, Nov 06 2006
  • Mathematica
    Table[Sum[DigitCount[n][[i]] i^6, {i, 9}], {n, 0, 40}] (* Bruno Berselli, Feb 01 2013 *)
  • PARI
    A055015(n)=sum(i=1,#n=digits(n),n[i]^6) \\ M. F. Hasler, Apr 12 2015

Formula

a(n) = Sum_{k>0} (floor(n/10^k) - 10*floor(n/10^(k+1)))^6. - Hieronymus Fischer, Jun 25 2007
a(10n+k) = a(n) + k^6, 0 <= k < 10. - Hieronymus Fischer, Jun 25 2007

A169665 Numbers divisible by the sum of 4th powers of their digits.

Original entry on oeis.org

1, 10, 100, 102, 110, 111, 1000, 1010, 1011, 1020, 1100, 1101, 1110, 1121, 1122, 1634, 2000, 2322, 4104, 5000, 8208, 9474, 10000, 10010, 10011, 10100, 10101, 10110, 10200, 10412, 11000, 11001, 11010, 11100, 11210, 11220, 12502, 12521, 14758
Offset: 1

Views

Author

Michel Lagneau, Apr 05 2010

Keywords

Examples

			12521 is a term since 1^4 + 2^4 + 5^4 + 2^4 + 1^4 = 659, and 12521 = 19*659;
89295 is a term since 8^4 + 9^4 + 2^4 + 9^4 + 5^4 = 17859, and 89295 = 5*17859.
		

Crossrefs

Programs

  • Maple
    A:= proc(n) add(d^4, d=convert(n, base, 10)) ; end proc: for n from 1 to 200000 do:if irem( n,A(n))=0 then printf(`%d, `,n):else fi:od:
  • Mathematica
    Select[Range[15000], Divisible[#, Plus @@ (IntegerDigits[#]^4)] &] (* Amiram Eldar, Jan 31 2021 *)

Formula

Numbers k such that A055013(k) | k.

A226224 The largest value of k in base n for which the sum of digits of k = sqrt(k).

Original entry on oeis.org

1, 25, 9, 64, 100, 144, 49, 64, 81, 225, 121, 441, 169, 441, 441, 256, 289, 324, 361, 1296, 1296, 484, 529, 1089, 625, 676, 729, 2401, 841, 2601, 961, 1024, 3025, 1156, 2500, 4096, 1369, 1444, 4356, 3136, 1681, 4900, 1849, 5929, 3025, 2116, 2209, 6561, 2401
Offset: 2

Views

Author

Keywords

Comments

There are no values of k in base n with more than 3 digits. Proof: such a value with d digits would need to meet the criterion d*(n-1)>=sqrt(n)^d which establishes an upper limit of 4 digits for 2<=n<=6 and 3 for n>6. Because there are no four digit values of k in bases 2 through 6, k has a maximum of three digits in all bases.
Because k must be a square, there are only sqrt(n)^3 possible values in any base.
From the above, it can be shown that for three-digit fixed points of the form xyz, x <= 6; also x<=4 for n>846. These theoretical upper limits are statistically unlikely, and in fact of the 86356 solutions in bases 2 to 10000, only 6.5% of them begin with 2, and none begin with 3 through 6.
a(n)=1 iff A226087(n)=1. Conjecture: this occurs exactly once -- in base 2.

Examples

			For a(16) the solutions are the square numbers {1, 36=6^2, 100=10^2, 225=15^2, 441=21^2} because in base 16 they are written as {1, 24, 64, E1, 1B9} and 1 = 1, 6 = 2+4, 10 = 6+4, 15 = 14+1, and 21 = 1+11+9.
		

Crossrefs

Programs

  • R
    for(n in 2:500) cat("Base",n,":",which(sapply((1:(ifelse(n>6,7,1)*n^ifelse(n>6,1,2)))^2, function(x) sum(inbase(x,n))==sqrt(x)))^2, "\n")

A123253 Sum of 7th powers of digits of n.

Original entry on oeis.org

0, 1, 128, 2187, 16384, 78125, 279936, 823543, 2097152, 4782969, 1, 2, 129, 2188, 16385, 78126, 279937, 823544, 2097153, 4782970, 128, 129, 256, 2315, 16512, 78253, 280064, 823671, 2097280, 4783097, 2187, 2188, 2315, 4374, 18571, 80312, 282123
Offset: 0

Views

Author

Zerinvary Lajos, Nov 06 2006

Keywords

Comments

Fixed points are listed in A124068 = row n=7 of A252648. - M. F. Hasler, Apr 12 2015

Crossrefs

Programs

  • Magma
    [0] cat [&+[d^7: d in Intseq(n)]: n in [1..40]]; // Bruno Berselli, Feb 01 2013
    
  • Maple
    A123253 := proc(n)
            add(d^7,d=convert(n,base,10)) ;
    end proc: # R. J. Mathar, Jan 16 2013
  • Mathematica
    Table[Sum[DigitCount[n][[i]] i^7, {i, 9}], {n, 0, 40}] (* Bruno Berselli, Feb 01 2013 *)
  • PARI
    A123253(n)=sum(i=1,#n=digits(n),n[i]^7) \\ M. F. Hasler, Apr 12 2015

A210767 Numbers whose digit sum as well as sum of the 4th powers of the digits is a prime.

Original entry on oeis.org

11, 12, 14, 16, 21, 23, 25, 29, 32, 34, 38, 41, 43, 47, 52, 58, 61, 67, 74, 76, 83, 85, 89, 92, 98, 101, 102, 104, 106, 110, 111, 113, 119, 120, 131, 133, 140, 146, 160, 164, 166, 179, 191, 197, 201, 203, 205, 209, 210, 223, 230, 232, 250, 269, 290, 296, 302
Offset: 1

Views

Author

Jonathan Vos Post, May 10 2012

Keywords

Comments

This is to the exponent 4 as A182404 is to the exponent 2.

Examples

			21 is in the sequence because sum of digits 2+1= 3 is prime, and sum of the 4th powers of the digits 2^4+1^4=17 is a prime.
		

Crossrefs

Programs

  • Mathematica
    Select[Range[350],AllTrue[{Total[IntegerDigits[#]],Total[ IntegerDigits[ #]^4]},PrimeQ]&] (* The program uses the AllTrue function from Mathematica version 10 *) (* Harvey P. Dale, Apr 01 2019 *)
  • PARI
    dspow(n,b,k)=my(s);while(n,s+=(n%b)^k;n\=b);s
    select(n->isprime(sumdigits(n))&&isprime(dspow(n,10,4)), vector(10^3, i, i)) \\ Charles R Greathouse IV, May 11 2012

Formula

{n such that A055013(n) and A007953(n) are both primes}.

A210840 Sum of the 8th powers of the digits of n.

Original entry on oeis.org

0, 1, 256, 6561, 65536, 390625, 1679616, 5764801, 16777216, 43046721, 1, 2, 257, 6562, 65537, 390626, 1679617, 5764802, 16777217, 43046722, 256, 257, 512, 6817, 65792, 390881, 1679872, 5765057, 16777472, 43046977, 6561, 6562, 6817, 13122, 72097, 397186
Offset: 0

Views

Author

Jonathan Vos Post, May 10 2012

Keywords

Comments

This is to exponent 8 as A007953 is to exponent 0, A003132 is to exponent 2, and A055013 is to exponent 4. The subsequence of primes (for n = 11, 12, 14, 21, 41, ...) begins 2, 257, 65537, 65537.

Examples

			a(12) = 1^8 + 2^8 = 257.
		

Crossrefs

Programs

  • Magma
    [0] cat [&+[d^8: d in Intseq(n)]: n in [1..35]]; // Bruno Berselli, Feb 01 2013
  • Mathematica
    Table[Total[IntegerDigits[n]^8], {n, 0, 100}] (* T. D. Noe, May 18 2012 *)
    Table[Sum[DigitCount[n][[i]] i^8, {i, 9}], {n, 0, 35}] (* Bruno Berselli, Feb 01 2013 *)

A362954 Numbers k such that k + the sum of the fourth powers of its digits is again a fourth power.

Original entry on oeis.org

0, 6047, 7518, 8127, 12207, 25247, 50000, 71966, 77326, 89582, 156156, 376189, 384624, 384640, 599611, 611356, 700158, 794139, 796715, 800558, 1172829, 1329051, 1329324, 1329340, 1488080, 1492525, 1862190, 2546894, 2547885, 5295852, 5302286, 5755548, 6244080, 6246510, 7291980, 7869294
Offset: 0

Views

Author

Will Gosnell and M. F. Hasler, May 09 2023

Keywords

Crossrefs

Cf. A000583 (4th powers), A055013 (sum of 4th powers of decimal digits of n).
Cf. A362953 (the same for 3rd powers).

Programs

  • PARI
    select( {is(n,p=4)=ispower(vecsum([d^p|d<-digits(n)])+n,p)}, [0..10^5])
    
  • Python
    aupto   = 7869300
    A362954 = []
    A000583 = set(fp**4 for fp in range(0, int(aupto**(1/4)+3)))
    for n in range(0, aupto+1):
        if n + sum(int(digit)**4 for digit in str(n)) in A000583: A362954.append(n)
    print(A362954) # Karl-Heinz Hofmann, Jun 02 2023
Showing 1-10 of 24 results. Next