A007770 Happy numbers: numbers whose trajectory under iteration of sum of squares of digits map (see A003132) includes 1.
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
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.
Links
- Jud McCranie, Table of n, a(n) for n = 1..143071
- Breeanne Baker Swart, Susan Crook, Helen G. Grundman, Laura Hall-Seelig, May Mei, and Laurie Zack, Fixed Points of Augmented Generalized Happy Functions II: Oases and Mirages, arXiv:1908.02194 [math.NT], 2019.
- T. Cai and X. Zhou, On the height of happy numbers, Rocky Mt. J. Math. 38 (6) (2008) 1921.
- E. El-Sedy and S. Siksek, On happy numbers, Rocky Mountain J. Math. 30 (2000), 565-570.
- Justin Gilmer, On the density of happy numbers, arXiv:1110.3836 [math.NT], 2011-2015.
- H. G. Grundmann, Semihappy Numbers, J. Int. Seq. 13 (2010), 10.4.8.
- B. L. Mayer and L. H. A. Monteiro, On the divisors of natural and happy numbers: a study based on entropy and graphs, AIMS Mathematics (2023) Vol. 8, Issue 6, 13411-13424.
- Luca Onnis, On a variant of the happy numbers and their generalizations, arXiv:2203.03381 [math.GM], 2022.
- Hao Pan, Consecutive happy numbers, arXiv:math/0607213 [math.NT], 2006.
- W. Schneider, Happy Numbers (Includes list of terms below 10000)
- R. Styer, Smallest Examples of Strings of Consecutive Happy Numbers, J. Int. Seq. 13 (2010), 10.6.3.
- Eric Weisstein's World of Mathematics, Happy Number
- Eric Weisstein's World of Mathematics, Digitaddition
- Wikipedia, Happy number
Crossrefs
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(6
M. 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)
Comments