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.

A020946 a(n) is the smallest number k such that A002487(k) = n.

Original entry on oeis.org

0, 1, 3, 5, 9, 11, 33, 19, 21, 35, 39, 37, 45, 43, 69, 73, 93, 77, 75, 83, 189, 85, 141, 139, 153, 151, 147, 155, 267, 149, 165, 173, 279, 275, 171, 283, 315, 277, 537, 325, 297, 293, 579, 301, 309, 365, 333, 299, 567, 331, 339, 553, 549, 563, 1275, 341, 585, 565, 615, 629
Offset: 0

Views

Author

N. J. A. Sloane and David W. Wilson, Jun 27 2002

Keywords

Examples

			A002487(33) = 6 and this is the first time 6 appears, so a(6) = 33.
		

Crossrefs

Programs

  • Mathematica
    aa = {}; a[0] = 0; a[1] = 1; a[n_] := a[n] = If[EvenQ[n], a[n/2], a[(n - 1)/2] + a[(n + 1)/2]]; Do[k = 0; While[a[k] != p, k++]; AppendTo[aa, k], {p, 0, 100}]; aa (* Artur Jasinski, Dec 06 2010 *)
  • PARI
    fusc(n)={my(a=1, b=0);while(n,if(bitand(n, 1), b+=a, a+=b);n>>=1); b};
    list(N)={
        my(v=vector(N),k);
        forstep(n=1,9e99,2,
            k=fusc(n);
            if(k<=N && !v[k],
                v[k]=n;
                if(vecmin(v),return(v))
            )
        )
    }; \\ Charles R Greathouse IV, Dec 20 2011
    
  • Python
    from itertools import count
    from functools import reduce
    def A020946(n): return next(filter(lambda k:sum(reduce(lambda x,y:(x[0],x[0]+x[1]) if int(y) else (x[0]+x[1],x[1]),bin(k)[-1:2:-1],(1,0)))==n,count(1))) if n else 0 # Chai Wah Wu, May 05 2023