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-2 of 2 results.

A271479 Number of steps for the trajectory of n under the map k -> A271478(k) to reach 1.

Original entry on oeis.org

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

Views

Author

N. J. A. Sloane, Apr 10 2016

Keywords

Comments

Arises in studying A266569.
Records are 0, 1, 4, 7, 10, 13, 16, 19, 22, 25, 28, 31, 34, 37, 40, ... and occur at positions 1, 2, 3, 5, 9, 17, 33, 65, 129, 257, 513, 1025, 2049, 4097, 8193, ...

Crossrefs

Programs

  • Maple
    f:=n->if n mod 2 = 0 then n/2 else 2*n+2; fi; # A271478
    a:=[]; B:=1000;
    for n from 1 to 100 do
       ct:=0; s:=n;
       for k from 1 to B while s>1 do
       s:=f(s); ct:=ct+1; od:
    if ct=B then lprint("error, need to increase limit B"); break; fi;
    a:=[op(a),ct]; od:
    a;
  • Mathematica
    Table[Length[NestWhileList[If[EvenQ[#],#/2,2#+2]&,n,#!=1&]]-1,{n,80}] (* Harvey P. Dale, May 02 2017 *)
  • PARI
    a(n) = if(n--, 3*(logint(n,2)+1) - 2*hammingweight(n), 0); \\ Kevin Ryde, Mar 21 2021

Formula

a(1) = 0; a(2*n) = a(n)+1; a(2*n+1) = a(n+1)+3. - Christian Krause, Mar 19 2021
a(n) = A000120(n-1) + 3*A023416(n-1), for n>=2. - Kevin Ryde, Mar 21 2021

A266569 a(1) = 1; thereafter a(2k) = 4k + a(k); a(2k+1) = k + a(4k+4).

Original entry on oeis.org

1, 5, 30, 13, 68, 42, 64, 29, 132, 88, 119, 66, 154, 92, 132, 61, 248, 168, 217, 128, 261, 163, 221, 114, 322, 206, 273, 148, 326, 192, 268, 125, 468, 316, 401, 240, 463, 293, 387, 208, 533, 345, 448, 251, 519, 313, 425, 210, 646, 422, 543, 310, 623, 381, 511
Offset: 1

Views

Author

Daniel Suteu, Jan 01 2016

Keywords

Examples

			For n=2, a(2) = 4 + a(1) = 5.
For n=3:
a(3) = 1 + a(8);
a(8) = 2*8 + a(8/2) = 16 + a(4);
a(4) = 2*4 + a(4/2) = 8 + a(2) = 13;
a(8) = 18+13 = 29;
a(3) = 1 + 29 = 30.
		

Crossrefs

Records (high water marks): A270811, A270812.

Programs

  • Maple
    A266569 := proc(n)
        option remember;
        local k;
        if n = 1 then
            1;
        elif type(n,'even') then
            2*n+procname(n/2) ;
        else
            k := (n-1)/2 ;
            k+procname(4*k+4) ;
        end if;
    end proc:
    seq(A266569(n),n=1..100) ; # R. J. Mathar, May 06 2016
  • Mathematica
    a[1] = 1; a[n_] := a[n] = If[EvenQ@ n, 2 n + a[n/2], (n - 1)/2 + a[2 (n + 1)]]; Array[a, 55] (* Michael De Vlieger, Jan 02 2016 *)
  • Sidef
    func a((1)) { 1 }
    func a(n {.is_even}) is cached { 2*n + a(n/2) }
    func a(n {.is_odd }) is cached { (n-1)/2 + a(2*(n + 1)) }
    1000.times { |n| say a(n) }
Showing 1-2 of 2 results.