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.

A068571 Number of happy numbers <= 10^n.

Original entry on oeis.org

1, 3, 20, 143, 1442, 14377, 143071, 1418854, 14255667, 145674808, 1492609148, 15091199357, 149121303586, 1443278000870, 13770853279685, 130660965862333, 1245219117260664, 12024696404768025, 118226055080025491, 1183229962059381238, 12005034444292997294
Offset: 0

Views

Author

Sascha Kurz, Mar 26 2002

Keywords

Examples

			For n=0, h(0,0) = 1 and h(0,x >0) = 0.
		

Crossrefs

Programs

  • PARI
    ssd(n)=n=digits(n); sum(i=1, #n, n[i]^2)
    happy(n)=while(n>6, n=ssd(n)); n==1
    a(n)=my(f=n!,s,d); forvec(v=vector(9,i,[0,n]), d=vector(9,i, if(i>8,n,v[i+1])-v[i]); if(happy(sum(i=1,9,d[i]*i^2)), s+=f/prod(i=1,9,d[i]!)/v[1]!), 1); s+1 \\ Charles R Greathouse IV, Nov 01 2016

Formula

From Bryan Wolf, Nov 06 2012: (Start)
h(n,x) = h(n-1,x-0^2) + h(n-1,x-1^2) + ... + h(n-1,x-9^2) where h() is the number of numbers of length n whose sum of the squares of their digits is x.
a(n) is the sum of all h(n, 0 < x <= 81*n), where x is a happy number, plus 1 for 10^n. (End)

Extensions

More terms from Lambert Klasen (Lambert.Klasen(AT)gmx.de), Nov 03 2004