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 15 results. Next

A003132 Sum of squares of digits of n.

Original entry on oeis.org

0, 1, 4, 9, 16, 25, 36, 49, 64, 81, 1, 2, 5, 10, 17, 26, 37, 50, 65, 82, 4, 5, 8, 13, 20, 29, 40, 53, 68, 85, 9, 10, 13, 18, 25, 34, 45, 58, 73, 90, 16, 17, 20, 25, 32, 41, 52, 65, 80, 97, 25, 26, 29, 34, 41, 50, 61, 74, 89, 106, 36, 37, 40, 45, 52, 61, 72, 85, 100, 117, 49
Offset: 0

Views

Author

Keywords

Comments

It is easy to show that a(n) < 81*(log_10(n)+1). - Stefan Steinerberger, Mar 25 2006
It is known that a(0)=0 and a(1)=1 are the only fixed points of this map. For more information about iterations of this map, see A007770, A099645 and A000216 ff. - M. F. Hasler, May 24 2009
Also known as the "Happy number map", since happy numbers A007770 are those whose trajectory under iterations of this map ends at 1. - M. F. Hasler, Jun 03 2025

References

  • N. J. A. Sloane and Simon Plouffe, The Encyclopedia of Integer Sequences, Academic Press, 1995 (includes this sequence).
  • Hugo Steinhaus, One Hundred Problems in Elementary Mathematics, Dover New York, 1979, republication of English translation of Sto Zadań, Basic Books, New York, 1964. Chapter I.2, An interesting property of numbers, pp. 11-12 (available on Google Books).

Crossrefs

Concerning iterations of this map, see A003621, A039943, A099645, A031176, A007770, A000216 (starting with 2), A000218 (starting with 3), A080709 (starting with 4, this is the only nontrivial limit cycle), A000221 (starting with 5), A008460 (starting with 6), A008462 (starting with 8), A008463 (starting with 9), A139566 (starting with 15), A122065 (starting with 74169). - M. F. Hasler, May 24 2009
Cf. A080151, A051885 (record values and where they occur).

Programs

  • Haskell
    a003132 0 = 0
    a003132 x = d ^ 2 + a003132 x' where (x', d) = divMod x 10
    -- Reinhard Zumkeller, May 10 2015, Aug 07 2012, Jul 10 2011
    
  • Magma
    [0] cat [&+[d^2: d in Intseq(n)]: n in [1..80]]; // Bruno Berselli, Feb 01 2013
    
  • Maple
    A003132 := proc(n) local d; add(d^2,d=convert(n,base,10)) ; end proc: # R. J. Mathar, Oct 16 2010
  • Mathematica
    Table[Sum[DigitCount[n][[i]]*i^2, {i, 1, 9}], {n, 0, 40}] (* Stefan Steinerberger, Mar 25 2006 *)
    Total/@(IntegerDigits[Range[0,80]]^2) (* Harvey P. Dale, Jun 20 2011 *)
  • PARI
    A003132(n)=norml2(digits(n)) \\ M. F. Hasler, May 24 2009, updated Apr 12 2015
    
  • Python
    def A003132(n): return sum(int(d)**2 for d in str(n)) # Chai Wah Wu, Apr 02 2021

Formula

a(n) = n^2 - 20*n*floor(n/10) + 81*(Sum_{k>0} floor(n/10^k)^2) + 20*Sum_{k>0} floor(n/10^k)*(floor(n/10^k) - floor(n/10^(k+1))). - Hieronymus Fischer, Jun 17 2007
a(10n+k) = a(n)+k^2, 0 <= k < 10. - Hieronymus Fischer, Jun 17 2007
a(n) = A007953(A048377(n)) - A007953(n). - Reinhard Zumkeller, Jul 10 2011

Extensions

More terms from Stefan Steinerberger, Mar 25 2006
Terms checked using the given PARI code, M. F. Hasler, May 24 2009
Replaced the Maple program with a version which works also for arguments with >2 digits, R. J. Mathar, Oct 16 2010
Added ref to Porges. Steinhaus also treated iterations of this function in his Polish book Sto zadań, but I don't have access to it. - Don Knuth, Sep 07 2015

A039943 Every integer eventually goes to one of these under the "x goes to sum of squares of digits of x" map.

Original entry on oeis.org

0, 1, 4, 16, 20, 37, 42, 58, 89, 145
Offset: 0

Views

Author

Keywords

Comments

The subset of the first three terms also satisfies the current definition. An alternate definition would be: Periodic points of A003132. - M. F. Hasler, May 24 2009
Following I. Ja. Tanatar (Moscow), one can easily prove that, for a given x, there exists an iteration of the map f(x) given in the definition which reaches 1 or 89. Indeed, it is easy to see that if x has at least 3 digits, then f(x) < x. Therefore there exists an iteration of f with not more than 2 digits. For two-digit numbers the property is verified directly. See Kordemsky. - Vladimir Shevelev, May 06 2013

References

  • B. A. Kordemsky, Matematicheskaja Smekalka, Moscow, 1955, pp. 305 and 557 (in Russian).

Crossrefs

Cf. A003132 (the iterated map), A003621, A039943, A031176, A007770, A000216 (orbit of 2), A000218 (orbit of 3), A080709 (orbit of 4, the only nontrivial limit cycle), A000221 (orbit of 5), A008460 (orbit of 6), A008462 (orbit of 8), A008463 (orbit of 9), A139566 (orbit of 15), A122065 (orbit of 74169).

Programs

  • Haskell
    a039943 n = a039943_list !! n
    a039943_list = [0,1,4,16,20,37,42,58,89,145]
    -- Reinhard Zumkeller, Mar 16 2013
  • Mathematica
    lst = {}; Do[a = NestWhile[Plus @@ (IntegerDigits@#^2) &, n, Unequal, All]; If[FreeQ[lst, a], AppendTo[lst, a]], {n, 10^4}] (* Robert G. Wilson v, Jan 19 2006 *)
    Union[Table[NestWhile[Total[IntegerDigits[#]^2]&,n,Unequal,All],{n,0,100}]] (* Harvey P. Dale, Nov 26 2013 *)

A000216 Take sum of squares of digits of previous term, starting with 2.

Original entry on oeis.org

2, 4, 16, 37, 58, 89, 145, 42, 20, 4, 16, 37, 58, 89, 145, 42, 20, 4, 16, 37, 58, 89, 145, 42, 20, 4, 16, 37, 58, 89, 145, 42, 20, 4, 16, 37, 58, 89, 145, 42, 20, 4, 16, 37, 58, 89, 145, 42, 20, 4, 16, 37, 58, 89, 145, 42, 20, 4, 16, 37, 58, 89, 145, 42, 20, 4, 16, 37
Offset: 1

Views

Author

Keywords

Comments

As the orbit of 2 under A003132, this could also have offset 0. Merges into A080709 right after the first term: a(n+1) = A080709(n) for all n >= 1. - M. F. Hasler, Apr 27 2018

References

  • R. Honsberger, Ingenuity in Mathematics, Random House, 1970, p. 83.
  • P. Kiss, A generalization of a problem in number theory, Math. Sem. Notes Kobe Univ., 5 (1977), no. 3, 313-317. MR 0472667 (57 #12362).

Crossrefs

Cf. A003132 (the iterated map), A003621, A039943, A099645, A031176, A007770, A000218 (starting with 3), A080709 (starting with 4), A000221 (starting with 5), A008460 (starting with 6), A008462 (starting with 8), A008463 (starting with 9), A139566 (starting with 15), A122065 (starting with 74169). - M. F. Hasler, May 24 2009

Programs

  • Haskell
    a000216 n = a000216_list !! (n-1)
    a000216_list = iterate a003132 2 -- Reinhard Zumkeller, Aug 24 2011
    
  • Magma
    [2] cat &cat[[4, 16, 37, 58, 89, 145, 42, 20]: n in [0..17]]; // Vincenzo Librandi, Jan 29 2013
  • Mathematica
    NestList[Total[IntegerDigits[#]^2]&, 2, 80] (* Vincenzo Librandi, Jan 29 2013 *)
  • PARI
    A000216(n)=[42, 20, 4, 16, 37, 58, 89, 145, 2][n%8+8^(n<2)] \\ M. F. Hasler, May 24 2009, edited Apr 27 2018
    

Formula

Periodic with period 8.

A099645 Number of iterations until n reaches a number in A039943 under "x goes to sum of squares of digits of x" map.

Original entry on oeis.org

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

Views

Author

Labos Elemer, Nov 08 2004

Keywords

Comments

Length of transient when the f[n]=Sum[digit^2 of n] function is iterated.
In A031176 including cycle lengths[=c] of this iteration only c=1 and c=8 occur. A007770 lists cases of c=1, the happy numbers.

Examples

			n=99999999999: iteration-list={99999999999,891,146,53,34,25,29,85,89,145,42,20,[4,16,37,58,89,145,42,20],4,...}. Lengths of transient=12, of cycle=8.
		

References

  • Hugo Steinhaus: "Sto zadan" (1958), "One Hundred Problems in Elementary Mathematics" (1964), problem 2. - M. F. Hasler, May 24 2009

Crossrefs

Cf. A039943, A031176, A007770, A000216 (orbit of 2), A000218 (orbit of 3), A080709 (orbit of 4), A000221 (orbit of 5), A008460 (orbit of 6), A008462 (orbit of 8), A008463 (orbit of 9), A139566 (orbit of 15), A122065 (orbit of 74169). - M. F. Hasler, May 24 2009

Programs

  • Haskell
    a099645 = length . takeWhile (`notElem` a039943_list) . iterate a003132
    a099645_list = map a099645 [1..]
    -- Reinhard Zumkeller, Aug 24 2011
  • Mathematica
    fu[x_] :=Apply[Plus, IntegerDigits[x]^2];hs=20; (* transient lengths are obtained by: *) a[n_] :=-1+Min[Flatten[Position[NestList[fu, n, Length[Union[NestList[fu, n, hs]]]] -Last[NestList[fu, n, Length[Union[NestList[fu, n, hs]]]]], 0]]]; Table[a[n], {n, 1, 256}]
  • PARI
    A099645(n)={ local( c=0, S=Set([1,4,16,37,58,89,145,42,20])); while( !setsearch(S,n), n=A003132(n); c++); c} \\ M. F. Hasler, May 24 2009
    

Extensions

Terms checked using the given PARI code. However, according to the domain of A003132 and the definition of A039943 (which both include 0), an initial a(0)=0 should be added here, too. - M. F. Hasler, May 24 2009

A000221 Take sum of squares of digits of previous term; start with 5.

Original entry on oeis.org

5, 25, 29, 85, 89, 145, 42, 20, 4, 16, 37, 58, 89, 145, 42, 20, 4, 16, 37, 58, 89, 145, 42, 20, 4, 16, 37, 58, 89, 145, 42, 20, 4, 16, 37, 58, 89, 145, 42, 20, 4, 16, 37, 58, 89, 145, 42, 20, 4, 16, 37, 58, 89, 145, 42, 20, 4, 16, 37, 58, 89, 145, 42, 20, 4, 16, 37, 58, 89, 145
Offset: 1

Views

Author

Keywords

Comments

Essentially the same as A080709, cf. formula. - M. F. Hasler, May 24 2009
As the orbit of 5 under A003132, this could as well start with index 0. - M. F. Hasler, Apr 27 2018

References

  • R. Honsberger, Ingenuity in Mathematics, Random House, 1970, p. 83.
  • James J. Tattersall, Elementary Number Theory in Nine Chapters, Cambridge University Press, 1999, page 25.

Crossrefs

Cf. A003132 (the iterated map), A003621, A039943, A099645, A031176, A007770, A000216 (starting with 2), A000218 (starting with 3), A080709 (starting with 4), A008460 (starting with 6), A008462 (starting with 8), A008463 (starting with 9), A139566 (starting with 15), A122065 (starting with 74169). - M. F. Hasler, May 24 2009

Programs

  • Haskell
    a000221 n = a000221_list !! (n-1)
    a000221_list = iterate a003132 5
    -- Reinhard Zumkeller, Mar 04 2013
  • Magma
    [5, 25, 29, 85] cat &cat[[89, 145, 42, 20, 4, 16, 37, 58]: n in [0..17]]; // Vincenzo Librandi, Jan 29 2013
    
  • Mathematica
    NestList[Plus @@ IntegerDigits[ # ]^2 &, 5, 50]
    PadRight[{5,25,29,85},120,{4,16,37,58,89,145,42,20}] (* Harvey P. Dale, Jan 14 2022 *)
  • PARI
    A000221(n)=[20,4,16,37,58,89,145,42,5,25,29,85][n%8+8^(n<5)] \\ M. F. Hasler, May 24 2009, edited Apr 27 2018
    

Formula

Ultimately periodic with period 8.
a(n) = A080709(n) for n >= 5. - M. F. Hasler, May 24 2009
a(n+1) = A003132(a(n)). - Reinhard Zumkeller, Dec 19 2011

A008460 Take sum of squares of digits of previous term; start with 6.

Original entry on oeis.org

6, 36, 45, 41, 17, 50, 25, 29, 85, 89, 145, 42, 20, 4, 16, 37, 58, 89, 145, 42, 20, 4, 16, 37, 58, 89, 145, 42, 20, 4, 16, 37, 58, 89, 145, 42, 20, 4, 16, 37, 58, 89, 145, 42, 20, 4, 16, 37, 58, 89, 145, 42, 20, 4, 16, 37, 58, 89, 145, 42, 20, 4, 16, 37, 58, 89, 145, 42, 20, 4
Offset: 1

Views

Author

Keywords

References

  • R. Honsberger, Ingenuity in Mathematics, Random House, 1970, p. 83.

Crossrefs

Cf. A003132 (the iterated map), A003621, A039943, A099645, A031176, A007770, A000216 (starting with 2), A000218 (starting with 3), A080709 (starting with 4), A000221 (starting with 5), A008462 (starting with 8), A008463 (starting with 9), A139566 (starting with 15), A122065 (starting with 74169). - M. F. Hasler, May 24 2009

Programs

  • Magma
    [6, 36, 45, 41, 17, 50, 25, 29, 85] cat &cat[[89, 145, 42, 20, 4, 16, 37, 58]: n in [0..17]]; // Vincenzo Librandi, Jan 29 2013
  • Mathematica
    NestList[Total[IntegerDigits[#]^2]&, 6, 80] (* Vincenzo Librandi, Jan 29 2013 *)
  • PARI
    A008460(n)=[6,36,45,41,17, 50,25,29,85,89, 145,42,20,4,16, 37,58][if(n<18,n,(n-10)%8+10)] \\ M. F. Hasler, May 24 2009
    

Formula

Periodic with period 8.
a(13+n) = A080709(n). - M. F. Hasler, May 24 2009

Extensions

An erroneous (duplicate) term deleted by M. F. Hasler, May 24 2009

A008462 Take sum of squares of digits of previous term; start with 8.

Original entry on oeis.org

8, 64, 52, 29, 85, 89, 145, 42, 20, 4, 16, 37, 58, 89, 145, 42, 20, 4, 16, 37, 58, 89, 145, 42, 20, 4, 16, 37, 58, 89, 145, 42, 20, 4, 16, 37, 58, 89, 145, 42, 20, 4, 16, 37, 58, 89, 145, 42, 20, 4, 16, 37, 58, 89, 145, 42, 20, 4, 16, 37, 58, 89, 145, 42, 20, 4, 16, 37, 58, 89, 145
Offset: 1

Views

Author

Keywords

References

  • R. Honsberger, Ingenuity in Math., Random House, 1970, p. 83.

Crossrefs

Cf. A003132 (the iterated map), A003621, A039943, A099645, A031176, A007770, A000216 (starting with 2), A000218 (starting with 3), A080709 (starting with 4), A000221 (starting with 5), A008460 (starting with 6), A008463 (starting with 9), A139566 (starting with 15), A122065 (starting with 74169). - M. F. Hasler, May 24 2009

Programs

  • Magma
    [8, 64, 52, 29, 85] cat &cat[[89, 145, 42, 20, 4, 16, 37, 58]: n in [0..17]]; // Vincenzo Librandi, Jan 29 2013
    
  • Mathematica
    NestList[Total[IntegerDigits[#]^2]&, 8, 80] (* Vincenzo Librandi, Jan 29 2013 *)
    PadRight[{8,64,52,29,85},80,{20,4,16,37,58,89,145,42}] (* Harvey P. Dale, Dec 27 2019 *)
  • PARI
    A008462(n)=[8, 64, 52, 29, 85, 89, 145, 42, 20, 4, 16, 37, 58][if(n>13,(n-6)%8+6,n)] \\ M. F. Hasler, May 24 2009
    
  • PARI
    Vec(x*(8 + 64*x + 52*x^2 + 29*x^3 + 85*x^4 + 89*x^5 + 145*x^6 + 42*x^7 + 12*x^8 - 60*x^9 - 36*x^10 + 8*x^11 - 27*x^12) / ((1 - x)*(1 + x)*(1 + x^2)*(1 + x^4)) + O(x^60)) \\ Colin Barker, Apr 28 2018

Formula

Periodic with period 8.
a(n) = A080709(n-1) for n >= 5 and a(n) = A000221(n-1) = A008460(n+4) for all n >= 4. - M. F. Hasler, May 24 2009; edited and extended Apr 27 2018
From Colin Barker, Apr 28 2018: (Start)
G.f.: x*(8 + 64*x + 52*x^2 + 29*x^3 + 85*x^4 + 89*x^5 + 145*x^6 + 42*x^7 + 12*x^8 - 60*x^9 - 36*x^10 + 8*x^11 - 27*x^12) / ((1 - x)*(1 + x)*(1 + x^2)*(1 + x^4)).
a(n) = a(n-8) for n>13.
(End)

A080709 Take sum of squares of digits of previous term, starting with 4.

Original entry on oeis.org

4, 16, 37, 58, 89, 145, 42, 20, 4, 16, 37, 58, 89, 145, 42, 20, 4, 16, 37, 58, 89, 145, 42, 20, 4, 16, 37, 58, 89, 145, 42, 20, 4, 16, 37, 58, 89, 145, 42, 20, 4, 16, 37, 58, 89, 145, 42, 20, 4, 16, 37, 58, 89, 145, 42, 20, 4, 16, 37, 58, 89, 145, 42, 20, 4, 16, 37
Offset: 1

Views

Author

N. J. A. Sloane, Mar 04 2003

Keywords

Comments

Occurs as puzzle in the Nintendo DS game "Professor Layton and the Diabolical Box". - M. F. Hasler, Dec 18 2009
From M. F. Hasler, Apr 27 2018: (Start)
As the orbit of 4 under A003132, this could rather have offset 0. Merges with the orbit of 5 at the 5th term of both sequences, and with other orbits as given in the formula section.
Porges gave his "set of eight numbers" as a(1)..a(8) in this order, rather than that of the set A039943. (End)

References

  • R. Honsberger, Ingenuity in Math., Random House, 1970, p. 83.

Crossrefs

Cf. A003132 (the iterated map), A003621, A039943, A099645, A031176, A007770, A000216 (starting with 2), A000218 (starting with 3), A000221 (starting with 5), A008460 (starting with 6), A008462 (starting with 8), A008463 (starting with 9), A139566 (starting with 15), A122065 (starting with 74169). - M. F. Hasler, May 24 2009

Programs

  • Haskell
    a080709 n = a080709_list !! (n-1)
    a080709_list = iterate a003132 4
    -- Reinhard Zumkeller, Aug 24 2011
    
  • Magma
    &cat[[4, 16, 37, 58, 89, 145, 42, 20]: n in [0..17]]; // Vincenzo Librandi, Jan 29 2013
  • Mathematica
    NestList[Total[IntegerDigits[#]^2]&, 4, 80] (* Vincenzo Librandi, Jan 29 2013 *)
  • PARI
    A080709(n)=[4, 16, 37, 58, 89, 145, 42, 20][(n-1)%8+1] \\ M. F. Hasler, May 24 2009
    

Formula

Periodic with period 8.
a(n) = A000216(n+1). - R. J. Mathar, Sep 19 2008
By definition, a(n+1) = A003132(a(n)) for n >= 1. a(n) = A000221(n) = A000218(n+3) = A008460(n+6) = A008462(n+1) = A008463(n+2) = A122065(n+3) = A139566(n+2) for n >= 8 or earlier. - M. F. Hasler, May 24 2009, edited Apr 27 2018

A122065 Take sum of squares of digits of previous term; start with 74169.

Original entry on oeis.org

74169, 183, 74, 65, 61, 37, 58, 89, 145, 42, 20, 4, 16, 37, 58, 89, 145, 42, 20, 4, 16, 37, 58, 89, 145, 42, 20, 4, 16, 37, 58, 89, 145, 42, 20, 4, 16, 37, 58, 89, 145, 42, 20, 4, 16, 37, 58, 89, 145, 42, 20, 4, 16, 37, 58, 89, 145, 42, 20, 4, 16, 37, 58, 89, 145, 42, 20, 4
Offset: 1

Views

Author

Herman Jamke (hermanjamke(AT)fastmail.fm), Sep 14 2006

Keywords

Comments

From a quiz, cf. Russel & Carter reference.

References

  • K. Russell and P. Carter, Number Puzzles, W. Foulsham and Co. Ltd. (1993).

Crossrefs

Cf. A000216 (main entry for related sequences), A003132 (the iterated "sum digits squared" map).

Programs

  • Magma
    [74169, 183, 74, 65, 61] cat &cat[[37, 58, 89, 145, 42, 20, 4, 16]: n in [0..17]]; // Vincenzo Librandi, Jan 29 2013
    
  • Mathematica
    NestList[Total[IntegerDigits[#]^2]&, 74169, 80] (* Vincenzo Librandi, Jan 29 2013 *)
  • PARI
    A122065_vec=vector(50,n,t=if(n>1,norml2(digits(t)),74169));
    A122065(n)=A122065_vec[n%8+(n>7)*8] \\ M. F. Hasler, Apr 27 2018

Formula

a(n) = A000218(n) for n >= 4, a(n) = A000216(n-2) for n >= 6. - M. F. Hasler, Apr 27 2018

A003621 Number of iterations until n reaches 1 or 4 under x goes to sum of squares of digits map.

Original entry on oeis.org

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

Views

Author

Keywords

References

  • J. Roberts, Lure of the Integers, Math. Assoc. America, 1992, p. 13.
  • N. J. A. Sloane and Simon Plouffe, The Encyclopedia of Integer Sequences, Academic Press, 1995 (includes this sequence).

Crossrefs

Cf. A000216, A000218, A300081, etc.
Cf. A003132.

Programs

  • Maple
    f:= n -> convert(map(t -> t^2, convert(n,base,10)),`+`):
    g:= proc(n) option remember;
      if n = 1 or n = 4 then 0 else 1 + procname(f(n)) fi
    end proc:
    map(g, [$1..100]); # Robert Israel, Apr 11 2019
  • Mathematica
    Table[Length[NestWhileList[Total[IntegerDigits[#]^2]&,n,#!=1&&#!=4&]],{n,80}]-1 (* Harvey P. Dale, Dec 31 2016 *)

Formula

a(n) = 0 if n = 1 or 4, otherwise a(n) = 1 + a(A003132(n)). - Robert Israel, Apr 11 2019
Showing 1-10 of 15 results. Next