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 10 results.

A154716 Products of three consecutive happy primes A035497.

Original entry on oeis.org

1729, 5681, 13547, 56327, 237553, 789289, 1089019, 1560553, 2530217, 4480109, 7703209, 12131401, 18417101, 24119467, 30355679, 38022301, 46039783, 53272619, 57627329, 62188859, 79075651, 112140029, 169169677, 226833263, 271152373, 300157327, 325898231
Offset: 1

Views

Author

Omar E. Pol, Jan 18 2009

Keywords

Comments

Note that a(1) = 1729 is the Hardy-Ramanujan number (see taxicab numbers in A001235, A011541).

Crossrefs

Programs

  • Mathematica
    happyQ[n_, b_] := NestWhile[Total[IntegerDigits[#, b]^2] &, n, UnsameQ, All] == 1; Times @@@ Partition[Select[Prime[Range[150]], happyQ[#, 10] &], 3, 1] (* Amiram Eldar, Jan 17 2025 *)

Extensions

a(5)-a(27) from Nathaniel Johnston, Apr 30 2011

A154717 Products of three distinct happy primes A035497.

Original entry on oeis.org

1729, 2093, 2821, 3059, 4123, 4991, 5681, 7189, 7657, 8827, 9269, 9373, 9919, 10507, 12649, 12719, 12901, 13547, 13699, 14497, 15197, 15617, 16583, 17143, 17549, 17563, 18487, 19513, 21049, 21749, 22211, 22351, 22379, 23621, 23653, 23933, 23959, 25441
Offset: 1

Views

Author

Omar E. Pol, Jan 18 2009

Keywords

Comments

Note that a(1)=1729 is the Hardy-Ramanujan number (see taxicab numbers in A001235, A011541).

Crossrefs

Extensions

a(5) - a(38) from Nathaniel Johnston, Apr 30 2011

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)

A046519 Least n-digit 'happy' prime.

Original entry on oeis.org

7, 13, 103, 1009, 10009, 100003, 1000003, 10000121, 100000039, 1000000009, 10000000033, 100000000003, 1000000000039, 10000000000411, 100000000000067, 1000000000000487, 10000000000000481, 100000000000000003
Offset: 1

Views

Author

Patrick De Geest, Sep 15 1998

Keywords

Comments

Values found by Harvey Heinz and Jud McCranie.

References

  • R. K. Guy, Unsolved Problems Number Theory, Sect. E34.

Crossrefs

Programs

  • Python
    from sympy import nextprime
    def A046519(n):
        m = 10**(n-1)
        while (m:=nextprime(m)):
            k = m
            while k not in {1,37,58,89,145,42,20,4,16}:
                k = sum((0, 1, 4, 9, 16, 25, 36, 49, 64, 81)[ord(d)-48] for d in str(k))
            if k == 1:
                return m # Chai Wah Wu, Aug 02 2023

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).

A109902 Happy primes of the form a*10^k + b with single-digit a and b, a > 0, k > 0.

Original entry on oeis.org

13, 19, 23, 31, 79, 97, 103, 109, 409, 709, 907, 1009, 2003, 3001, 9001, 9007, 10009, 40009, 70009, 90001, 90007, 100003, 200003, 400009, 900001, 900007, 1000003, 2000003, 7000009, 20000003, 30000001, 400000009, 1000000009, 4000000009, 9000000001
Offset: 1

Views

Author

Paul Muljadi, Jun 22 2007

Keywords

Comments

The subset of numbers of A035497 with the internal digits in the decimal representation all zero.
A number is in this sequence if and only if it is a prime of the form a00...00b, where (a,b) is one of (1,3), (1,9), (2,3), (3,1), (4,9), (7,9), (9,1), or (9,7). - Nathaniel Johnston, Apr 30 2011

Crossrefs

Cf. A035497.

Programs

  • Maple
    A003132 := proc(n) local digs,i ; digs := convert(n,base,10) ; add( (op(i,digs))^2,i=1..nops(digs)) ; end: isA035497 := proc(n) local nItr ; nItr := n ; if isprime(n) then while true do if nItr = 0 or nItr=4 or nItr = 16 or nItr = 20 or nItr = 37 or nItr = 42 or nItr =58 or nItr =89 or nItr = 145 then RETURN(false) ; elif nItr = 1 then RETURN(true) ; fi ; nItr := A003132(nItr) ; od ; else false ; fi ; end: isA109902 := proc(n) local digs,d ; if isprime(n) and n > 9 then digs := convert(n,base,10) ; for d from 2 to nops(digs)-1 do if op(d,digs) <> 0 then RETURN(false) ; fi ; od ; RETURN(isA035497(n)) ; else RETURN(false) ; fi ; end: for i from 1 to 20000 do p := ithprime(i) : if isA109902(p) then printf("%d,",p) ; fi ; od:
    diglim:=20: dig:=[[1,3],[1,9],[2,3],[3,1],[4,9],[7,9],[9,1],[9,7]]: for k from 1 to diglim do for m from 1 to 8 do n:=dig[m][1]*10^k + dig[m][2]: if(isprime(n))then printf("%d, ",n): fi:od:od: # Nathaniel Johnston, Apr 30 2011
  • Mathematica
    Select[Sort[Flatten[With[{ab={{1,3},{1,9},{2,3},{3,1},{4,9},{7,9},{9,1},{9,7}}},Table[FromDigits[Join[PadRight[{ab[[n,1]]},i,0],{ab[[n,2]]}]],{n,8},{i,9}]]]],PrimeQ] (* Harvey P. Dale, May 31 2013 *)

Extensions

Edited by R. J. Mathar, Jul 13 2007
a(24) - a(35) from Nathaniel Johnston, Apr 30 2011

A343192 Happy Honaker primes.

Original entry on oeis.org

263, 1039, 1933, 2221, 3067, 3137, 5741, 6343, 6353, 6971, 7481, 8821, 9103, 10247, 11251, 12347, 13037, 13339, 13457, 13933, 14437, 16451, 17317, 18041, 21617, 26309, 26339, 30091, 30293, 31177, 32009, 34471, 35227, 36307, 36433, 37117, 41131, 41333, 41801, 43781
Offset: 1

Views

Author

K. D. Bajpai, Apr 07 2021

Keywords

Comments

Intersection of A033548 and A035497 or A007770.

Examples

			263 is a Honaker prime: the number of primes up to 263 is 56 and 2 + 6 + 3 = 11 = 5 + 6. 263 is also a Happy number: iterating the sum of squares of digits terminates in 1, i.e., 263 -> 4 + 36 + 9 = 49 -> 16 + 81 = 97 -> 81 + 49 = 130 -> 1 + 9 + 0 = 10 -> 1 + 0 = 1. Thus 263 is a Happy Honaker prime.
		

Crossrefs

Programs

  • Mathematica
    Select[Prime[Range[20000]], FixedPoint[Total[IntegerDigits[#]^2] &, #, 10] == 1 && Plus @@ IntegerDigits@# == Plus @@ IntegerDigits@PrimePi@# &]

A215932 Happy reversible primes.

Original entry on oeis.org

7, 13, 31, 79, 97, 167, 313, 383, 709, 739, 761, 907, 937, 1009, 1033, 1151, 1487, 1511, 1733, 1847, 1933, 3019, 3067, 3083, 3109, 3301, 3319, 3371, 3391, 3463, 3643, 3803, 7457, 7481, 7547, 7589, 7603, 7841, 9001, 9013, 9103, 9133, 9857, 10009, 10039, 10067
Offset: 1

Views

Author

Jayanta Basu, Mar 16 2013

Keywords

Comments

Happy numbers that are prime and if the digits are reversed they remain prime (and of course happy, since addition is commutative).
Intersection of A007500 and A007770. - N. J. A. Sloane, Mar 16 2013
This is to A031161 (palindromic lucky numbers) as prime happy numbers are to lucky numbers (A000959). - Jonathan Vos Post, Mar 16 2013

Crossrefs

Programs

  • C
    int main()
    {long unsigned int n,i,si,a[]={4,16,37,58,89,145,42,20},t,x,c1=0, sod(long unsigned int),rev(long unsigned int),prim(long unsigned int);
    for(n=2;n<=12000;n++) {t=n;si=0;while(si!=1){for(i=0;i<=7;i++){if(t==a[i]){si=1;break;}}
                            if(t==1){si=1;if(prim(n)==0){x=rev(n);if(prim(x)==0){printf(", %lu",n);c1=c1+1;}}}t=sod(t);}}}
    long unsigned int sod(long unsigned int m){long unsigned int d=0,r;while(m>0){r=m%10;d=d+r*r;m=m/10;} return(d);}
    long unsigned int rev(long unsigned int p){long unsigned int d=0,r;while(p>0){r=p%10;d=d*10+r;p=p/10;}return(d);}
    long unsigned int prim(long unsigned int n){long unsigned int i,d=0; for(i=2;i<=n/2;i++){if(n%i==0){d=1;break;}}return(d);}
  • Mathematica
    revpQ[n_] := PrimeQ[n] && PrimeQ[FromDigits@Reverse@IntegerDigits@n]; happyQ[n_] := Block[{w = n}, While[w > 6, w = Total[ IntegerDigits[w]^2]]; w == 1]; Select[Range[10^4], revpQ[#] && happyQ[#] &] (* Giovanni Resta, Mar 16 2013 *)

A364786 We exclude powers of 10 and numbers of the form 11...111 in which the number of 1's is a power of 10. Then a(n) is the smallest number (not excluded) whose trajectory under iteration of "x -> sum of n-th powers of digits of x" reaches 1.

Original entry on oeis.org

19, 7, 112, 11123, 1111222, 111111245666689, 1111133333333335, 1111122333333333333333333346677777777888, 22222222222222222226666668888888, 233444445555555555555555555555555555555555555555555577, 1222222222233333333333333444444444455555555555555556666666666666666666666677778888889
Offset: 1

Views

Author

Simon R Blow, Aug 07 2023

Keywords

Comments

For n!=2, it appears that the first step in the trajectory is always to a power of 10, so that the task would be to find the shortest and lexicographically smallest partition of a power of 10 into parts 1^n,...,9^n.

Examples

			a(1) = 19 since 1^1 + 9^1 = 10 and 1^1 + 0^1 = 1.
a(3) = 112 since 1^3 + 1^3 + 2^3 = 10 and 1^3 + 0^3 = 1.
		

Crossrefs

Extensions

a(6), a(8), and a(9) corrected by, and a(10) and a(11) from Jon E. Schoenfield, Aug 10 2023
Definition clarified by N. J. A. Sloane, Sep 15 2023

A383290 Number of happy primes <= 10^n.

Original entry on oeis.org

1, 7, 35, 200, 1465, 11144, 91323, 812371, 7408754, 67982202, 621496655
Offset: 1

Views

Author

Shyam Sunder Gupta, Apr 22 2025

Keywords

Comments

The proportion of happy primes to total primes seems to follow the same pattern as the proportion of happy numbers to total numbers, at least up to 10^10.

Crossrefs

Extensions

a(11) from Amiram Eldar, Apr 23 2025
Showing 1-10 of 10 results.