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.

A335552 Triangle T(n,k) read by rows: in the Josephus problem with n initial numbers on a line: eliminate each second and reverse left-right-direction of elimination. T(n,k) is the (n-k+1)st element removed, 1<=k<=n.

Original entry on oeis.org

1, 3, 1, 3, 1, 4, 1, 5, 3, 4, 1, 5, 3, 6, 4, 3, 7, 1, 5, 6, 4, 3, 7, 1, 5, 8, 6, 4, 9, 1, 5, 3, 7, 8, 6, 4, 9, 1, 5, 3, 7, 10, 8, 6, 4, 11, 3, 7, 1, 5, 9, 10, 8, 6, 4, 11, 3, 7, 1, 5, 9, 12, 10, 8, 6, 4, 9, 1, 13, 5, 3, 7, 11, 12, 10, 8, 6, 4, 9, 1, 13, 5, 3, 7, 11, 14, 12, 10, 8, 6, 4, 11, 3, 15
Offset: 1

Views

Author

R. J. Mathar, Jun 22 2020

Keywords

Examples

			The triangle starts
   1
   3   1
   3   1   4
   1   5   3   4
   1   5   3   6   4
   3   7   1   5   6   4
   3   7   1   5   8   6   4
   9   1   5   3   7   8   6   4
   9   1   5   3   7  10   8   6   4
  11   3   7   1   5   9  10   8   6   4
  11   3   7   1   5   9  12  10   8   6   4
   9   1  13   5   3   7  11  12  10   8   6   4
   9   1  13   5   3   7  11  14  12  10   8   6   4
  11   3  15   7   1   5   9  13  14  12  10   8   6   4
  11   3  15   7   1   5   9  13  16  14  12  10   8   6   4
   1  17   9  13   5   3   7  11  15  16  14  12  10   8   6   4
   1  17   9  13   5   3   7  11  15  18  16  14  12  10   8   6   4
   3  19  11  15   7   1   5   9  13  17  18  16  14  12  10   8   6   4
   3  19  11  15   7   1   5   9  13  17  20  18  16  14  12  10   8   6   4
		

Crossrefs

Cf. A090569 (column k=1).

Programs

  • Maple
    sigr := proc(n,r)
        floor(n/2^r) ;
    end proc:
    # A063695
    f := proc(n)
        local ndigs,fn,k ;
        ndigs := convert(n,base,2) ;
        fn := 0 ;
        for k from 2 to nops(ndigs) by 2 do
            fn := fn+op(k,ndigs)*2^(k-1)
        end do;
        fn ;
    end proc:
    g := proc(t,n)
        local r;
        if t =1 then
            0 ;
        elif t > 1 then
            r := ilog2( (n-1)/(t-1) ) ;
            (-2)^r*(f( sigr(2*n-1,r) )+f( sigr(n-1,r) )-2*t+3) ;
        end if;
    end proc:
    ft := proc(t,n)
        f(n-1)+1+g(t,n) ;
    end proc:
    for n from 1 to 20 do
        for t from 1 to n-1 do
            printf("%3d ", ft(t,n)) ;
        end do:
        printf("\n") ;
    end do: