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

A193995 Maximum number of terms required to determine whether a number is happy or not (A007770 or A031177).

Original entry on oeis.org

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

Views

Author

T. D. Noe, Aug 23 2011

Keywords

Comments

The number 1 is the only term requiring just one term to determine if it is happy. Although the b-file appears to show that there are only a few numbers having 8 terms, see A193996 for more beginning at 78999.

Examples

			For n=2, a(n)=9 because the iterations are 2, 4, 16, 37, 58, 89, 145, 42, 20, 4, 16,...
		

Programs

  • Mathematica
    f[n_] := Total[IntegerDigits[n]^2]; Table[Length[NestWhileList[f, n, UnsameQ, All]] - 1, {n, 100}]

A193996 Numbers that require exactly 8 iterations to determine that they are happy or not (A007770 and A031177).

Original entry on oeis.org

4, 16, 20, 37, 42, 58, 89, 145, 78999, 79899, 79989, 79998, 87999, 89799, 89979, 89997, 97899, 97989, 97998, 98799, 98979, 98997, 99789, 99798, 99879, 99897, 99978, 99987, 378999, 379899, 379989, 379998, 387999, 389799, 389979, 389997, 389999, 397899, 397989
Offset: 1

Views

Author

T. D. Noe, Aug 23 2011

Keywords

Comments

This sequence begins with the last 8 numbers of A039943. The number 78999 is the first happy number here.

Programs

  • Mathematica
    f[n_] := Total[IntegerDigits[n]^2]; Select[Range[400000], Length[NestWhileList[f, #, UnsameQ, All]] - 1 == 8 &]

A007770 Happy numbers: numbers whose trajectory under iteration of sum of squares of digits map (see A003132) includes 1.

Original entry on oeis.org

1, 7, 10, 13, 19, 23, 28, 31, 32, 44, 49, 68, 70, 79, 82, 86, 91, 94, 97, 100, 103, 109, 129, 130, 133, 139, 167, 176, 188, 190, 192, 193, 203, 208, 219, 226, 230, 236, 239, 262, 263, 280, 291, 293, 301, 302, 310, 313, 319, 320, 326, 329, 331, 338
Offset: 1

Views

Author

N. J. A. Sloane, A.R.McKenzie(AT)bnr.co.uk

Keywords

Comments

Sometimes called friendly numbers, but this usage is deprecated.
Gilmer shows that the lower density of this sequence is < 0.1138 and the upper density is > 0.18577. - Charles R Greathouse IV, Dec 21 2011
Corrected the upper and lower density inequalities in the comment above. - Nathan Fox, Mar 14 2013
Grundman defines the heights of the happy numbers by the number of iterations needed to reach the 1: 0, 5, 1, 2, 4, 3, 3, 2, 3, 4, 4, 2, 5, 3, 3, 2, 4, 4, 3, 1, ... (A090425(n) - 1). E.g., for n=2 the height of 7 is 5 because it needs 5 iterations: 7 -> 49 -> 97 -> 130 -> 10 -> 1. - R. J. Mathar, Jul 09 2017
El-Sedy & Siksek prove that this sequence contains arbitrarily long subsequences of consecutive terms; that is, the upper uniform density of this sequence is 1. - Charles R Greathouse IV, Sep 12 2022

Examples

			1 is OK. 2 --> 4 --> 16 --> 37 --> ... --> 4, which repeats with period 8, so never reaches 1, so 2 (and 4) are unhappy.
A correspondent suggested that 98 is happy, but it is not. It enters a cycle 98 -> 145 -> 42 -> 20 -> 4 -> 16 ->37 ->58 -> 89 -> 145 ...
		

References

  • L. E. Dickson, History of the Theory of Numbers, Vol, I: Divisibility and Primality, AMS Chelsea Publ., 1999.
  • R. K. Guy, Unsolved Problems Number Theory, Sect. E34.
  • J. N. Kapur, Reflections of a Mathematician, Chap. 34 pp. 319-324, Arya Book Depot New Delhi 1996.
  • James J. Tattersall, Elementary Number Theory in Nine Chapters, Cambridge University Press, 1999, pages 25-26.

Crossrefs

Cf. A003132 (the underlying map), A001273, A035497 (happy primes), A046519, A031177, A002025, A050972, A050973, A074902, A103369, A035502, A068571, A072494, A124095, A219667, A239320 (base 3), A240849 (base 5).
Cf. A090425 (required iterations including start and end).

Programs

  • Haskell
    a007770 n = a007770_list !! (n-1)
    a007770_list = filter ((== 1) . a103369) [1..]
    -- Reinhard Zumkeller, Aug 24 2011
    
  • Mathematica
    f[n_] := Total[IntegerDigits[n]^2]; Select[Range[400], NestWhile[f, #, UnsameQ, All] == 1 &] (* T. D. Noe, Aug 22 2011 *)
    Select[Range[1000],FixedPoint[Total[IntegerDigits[#]^2]&,#,10]==1&] (* Harvey P. Dale, Oct 09 2011 *)
    (* A example with recurrence formula to test if a number is happy *)
    a[1]=7;
    a[n_]:=Sum[(Floor[a[n-1]/10^k]-10*Floor[a[n-1]/10^(k+1)]) ^ (2) ,{k, 0,
          Floor[Log[10,a[n-1]]] }]
    Table[a[n],{n,1,10}] (* José de Jesús Camacho Medina, Mar 29 2014 *)
  • PARI
    ssd(n)=n=digits(n);sum(i=1,#n,n[i]^2)
    is(n)=while(n>6,n=ssd(n));n==1 \\ Charles R Greathouse IV, Nov 20 2012
    
  • PARI
    select( {is_A007770(n)=while(6M. F. Hasler, Dec 20 2024
    
  • Python
    def ssd(n): return sum(int(d)**2 for d in str(n))
    def ok(n):
      while n not in [1, 4]: n = ssd(n) # iterate until fixed point or in cycle
      return n==1
    def aupto(n): return [k for k in range(1, n+1) if ok(k)]
    print(aupto(338)) # Michael S. Branicky, Jan 07 2021

Formula

From Ulrich Krug (leuchtfeuer37(AT)gmx.de), Apr 23 2009: (Start)
1) Every power 10^k is a member of the sequence.
2) If n is member the numbers obtained by placing zeros anywhere in n are members.
3) If n is member each permutation of digits of n gives another member.
4) If the repeated process of summing squared digits give a number which is already a member of sequence the starting number belongs to the sequence.
5) If n is a member the repunit consisting of n 1's is a member.
6) If n is a member delete any digit d, new number consisting of remaining digits of n and d^2 1's placed everywhere to n is a member.
7) It is conjectured that the sequence includes an infinite number of primes (see A035497).
8) For any starting number the repeated process of summing squared digits ends with 1 or gives an "8-loop" which ends with (37,58,89,145,42,20,4,16,37) (End)

A056527 Numbers where iterated sum of digits of square settles down to a cyclic pattern (in fact 13, 16, 13, 16, ...).

Original entry on oeis.org

2, 4, 5, 7, 11, 13, 14, 16, 20, 22, 23, 25, 29, 31, 32, 34, 38, 40, 41, 43, 47, 49, 50, 52, 56, 58, 59, 61, 65, 67, 68, 70, 74, 76, 77, 79, 83, 85, 86, 88, 92, 94, 95, 97, 101, 103, 104, 106, 110, 112, 113, 115, 119, 121, 122, 124, 128, 130, 131, 133, 137, 139, 140
Offset: 1

Views

Author

Henry Bottomley, Jun 19 2000

Keywords

Comments

Numbers == 2, 4, 5 or 7 mod 9, i.e. such that n^4 is not congruent to n^2 mod 9.
Numbers congruent to {2, 4, 5, 7} mod 9.

Examples

			a(1)=2 because iteration starts 2, 4, 7, 13, 16, 13, 16, ....
		

Crossrefs

Cf. A004159 for sum of digits of square, A056020 where iteration settles to 1, A056020 where iteration settles to 9, also A056528, A056529. Unhappy numbers A031177 deal with iteration of square of sum of digits not settling to a single result.

Programs

  • Mathematica
    Flatten[Table[9n+{2,4,5,7},{n,0,20}]] (* or *) LinearRecurrence[{1,0,0,1,-1},{2,4,5,7,11},100] (* Harvey P. Dale, Apr 05 2015 *)
  • PARI
    Vec(x*(2 + 2*x + x^2 + 2*x^3 + 2*x^4) / ((1 - x)^2*(1 + x)*(1 + x^2)) + O(x^80)) \\ Colin Barker, Dec 19 2017

Formula

a(n) = a(n-1) + a(n-4) - a(n-5) for n>5. - Harvey P. Dale, Apr 05 2015
From Colin Barker, Dec 19 2017: (Start)
G.f.: x*(2 + 2*x + x^2 + 2*x^3 + 2*x^4) / ((1 - x)^2*(1 + x)*(1 + x^2)).
a(n) = (-9 + (-1)^(1+n) - (3-3*i)*(-i)^n - (3+3*i)*i^n + 18*n) / 8 where i=sqrt(-1).
(End)

A103369 Number in the 2-digitaddition sequence at which the eventually periodic part starts.

Original entry on oeis.org

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

Views

Author

Eric W. Weisstein, Feb 02 2005

Keywords

Comments

a(A007770(n)) = 1; a(A031177(n)) > 1. - Reinhard Zumkeller, Mar 16 2013

Examples

			The 2-digitaddition sequence for n = 3 is {3, 9, 81, 65, 61, 37, 58, 89, 145, 42, 20, 4, 16, 37, ...}, so a(3) = 37.
		

Crossrefs

Programs

  • Haskell
    a103369 = until (`elem` a039943_list) a003132
    a103369_list = map a103369 [1..]
    -- Reinhard Zumkeller, Oct 17 2011, Aug 24 2011

A161872 Smallest unhappy number in base n (or 0 if no unhappy numbers in the base).

Original entry on oeis.org

0, 2, 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 2, 7, 2, 3, 2, 2, 2, 2, 2, 2, 2, 2, 2, 5, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2
Offset: 2

Views

Author

Jud McCranie, Jun 20 2009

Keywords

Comments

All positive integers are happy numbers in base 2 and base 4; they are called "happy bases". There are no other happy bases < 500,000,000.

Crossrefs

Cf. A031177 (Unhappy numbers in base 10).

Programs

  • Mathematica
    Table[If[MemberQ[{2, 4}, n], 0, Block[{k = 2}, While[NestWhile[Total[IntegerDigits[#, n]^2] &, k, UnsameQ, All] == 1, k++]; k]], {n, 2, 105}] (* Michael De Vlieger, Nov 06 2018 *)
  • PARI
    A161872(n) = if((2==n)||(4==n),0, for(k=2, oo, my(visited = Map(), t = k); while(t!=1, if(mapisdefined(visited, t), return(k), mapput(visited, t, t)); t = vecsum(apply(d -> (d*d),digits(t,n)))))); \\ Antti Karttunen, Nov 06 2018

A094480 Unhappy primes, primes that are also unhappy numbers.

Original entry on oeis.org

2, 3, 5, 11, 17, 29, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 83, 89, 101, 107, 113, 127, 131, 137, 149, 151, 157, 163, 173, 179, 181, 191, 197, 199, 211, 223, 227, 229, 233, 241, 251, 257, 269, 271, 277, 281, 283, 307, 311, 317, 337, 347, 349, 353, 359, 373, 389
Offset: 1

Views

Author

Gerard Schildberger, Jun 05 2004

Keywords

Crossrefs

Cf. unhappy numbers (A031177), happy primes (A035497).

A161874 Bases with smallest unhappy number (in that base) > 2.

Original entry on oeis.org

16, 18, 20, 30, 130, 256, 1042, 4710, 7202, 10082, 47274, 65536, 65600, 351634, 426530, 431730, 764930, 5921514, 26639560, 32435910, 88605010, 97025190, 99562110
Offset: 1

Views

Author

Jud McCranie, Jun 20 2009

Keywords

Comments

a(12) > 50000, if it exists. - Amiram Eldar, Jun 16 2020
a(18) > 1.5*10^6, if it exists. The smallest unhappy numbers corresponding to bases a(1)-a(17) are 3, 7, 3, 5, 20, 3, 12, 3, 3, 14, 3, 3, 3, 3, 3, 3, 23. - Giovanni Resta, Jun 25 2020
The smallest unhappy numbers in bases (a(18), ..., a(23)) are (3, 23, 3, 261, 6, 12). - Lucas A. Brown, Apr 25 2023
a(24) > 10^8, if it exists. - Lucas A. Brown, Apr 25 2023

Examples

			In base 16, 2 is happy because the sequence it generates is 2 -> 4 -> (1,0) -> 1, while 3 is unhappy because the sequence it generates is 3 -> 9 -> (5,1) -> (1,10) -> (6,5) -> (3,13) -> (11,2) -> (7,13) -> (13,10) -> (1,0,13) -> (10,10) -> (12,8) -> (13,0) -> (10,9) -> (11,5) -> (9,2) -> (5,5) -> (3,2) -> (0,13) -> (10,9) -> ..., which repeats with period 6.
		

Crossrefs

Cf. A031177 (unhappy numbers in base 10), A161872, A362026.

Programs

  • Mathematica
    happyQ[n_, b_] := NestWhile[Total[IntegerDigits[#, b]^2] &, n, UnsameQ, All] == 1; Select[Range[2, 256], !MemberQ[{2, 4}, #] && happyQ[2, #] &] (* Amiram Eldar, Jun 16 2020 *)

Extensions

a(11) from Amiram Eldar, Jun 16 2020
a(12)-a(17) from Giovanni Resta, Jun 25 2020
a(18) from Lucas A. Brown, Aug 17 2022
a(19) from Lucas A. Brown, Aug 26 2022
a(20)-a(23) from Lucas A. Brown, Apr 25 2023

A209242 The largest fixed value (neither happy nor sad) in base n.

Original entry on oeis.org

8, 1, 18, 1, 45, 52, 50, 1, 72, 125, 160, 1, 128, 1, 261, 260, 200, 1, 425, 405, 490, 1, 338, 1, 657, 628, 450, 848, 936, 845, 1000, 832, 648, 1, 1233, 1377, 800, 1, 1450, 1445, 1813, 1341, 1058, 1856, 2125, 1844, 1250, 1525, 1352, 2205, 2560, 1, 2873, 1, 3200
Offset: 3

Views

Author

Keywords

Comments

A number is a fixed value if it is the sum of its own squared digits. Such values >1 are the only numbers that are neither happy (A007770) nor unhappy (A031177) in that base.
The number of fixed values in base B (A193583) is equal to one less than the number of divisors of (1+B^2) (Beardon, 1998, Theorem 3.1).
No fixed point has more than 2 digits in base B, and the two-digit number a+bB must satisfy the condition that (2a-1)^2+(2b-B)^2=1+B^2 (Beardon, 1998, Theorem 2.5). Since there are a finite number of ways to express 1+B^2 as the sum of two squares (A002654), this limits the search space.
Because fixed points have a maximum value of B^2-1 in base B, there are a large number of solutions near perfect squares, x^2. Surprisingly, there are also a large number of points near "half-squares", (x+.5)^2. See "Ulam spiral" in the links.

Examples

			a(7)=45 because in base 7, 45 is 63 and 6^2+3^2=45. The other fixed values in base 7 are 32, 25, 10 and (as always) 1.
		

Crossrefs

Programs

  • Python
    from sympy.ntheory.digits import digits
    def ssd(n, b): return sum(d**2 for d in digits(n, b)[1:])
    def a(n):
        m = n**2 - 1
        while m != ssd(m, n): m -= 1
        return m
    print([a(n) for n in range(3, 58)]) # Michael S. Branicky, Aug 01 2021
  • R
    #ya=number of fixed points, yb=values of those fixed points
    library(gmp); ya=rep(0,200); yb=vector("list",200)
    for(B in 3:200) {
      w=1+as.bigz(B)^2
      ya[B]=prod(table(as.numeric(factorize(w)))+1)-1
      x=1; y=0; fixpt=c()
      if(ya[B]>1) {
        while(2*x^2=0 & av=0 & bv
    				

Extensions

Program improved and sequence extended by Christian N. K. Anderson, Apr 25 2013.

A194041 Lucky numbers which are also unhappy numbers.

Original entry on oeis.org

3, 9, 15, 21, 25, 33, 37, 43, 51, 63, 67, 69, 73, 75, 87, 93, 99, 105, 111, 115, 127, 135, 141, 151, 159, 163, 169, 171, 189, 195, 201, 205, 211, 223, 231, 235, 237, 241, 259, 261, 267, 273, 283, 285, 289, 297, 303, 307, 321, 327, 339, 349, 357, 361, 385, 393
Offset: 1

Author

Jonathan Vos Post, Aug 12 2011

Keywords

Comments

An unhappy number is a number that is not happy (A007770) i.e., a number n such that iterating this sum-of-squared-digits map starting with n never reaches the number 1. Many asymptotic properties of the prime numbers are shared by the lucky numbers.

Crossrefs

Formula

A000959 INTERSECTION A031177. {k such that k is in A000959 and k is not in A007770}.
Showing 1-10 of 21 results. Next