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.

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

A270814 a(1)=0; thereafter a(2k)=k+a(k), a(2k+1)=6k+4+a(6k+4).

Original entry on oeis.org

0, 1, 46, 3, 31, 49, 281, 7, 330, 36, 248, 55, 106, 288, 679, 15, 197, 339, 500, 46, 127, 259, 610, 67, 633, 119, 101413, 302, 413, 694, 101073, 31, 808, 214, 505, 357, 498, 519, 2305, 66, 101290, 148, 1295, 281, 452, 633, 100932, 91, 757, 658, 1079, 145, 346, 101440, 102261, 330, 1596, 442, 2128
Offset: 1

Views

Author

N. J. A. Sloane, Apr 08 2016

Keywords

Comments

Inspired by A266569.
In other words, a(n) = n/2 + a(n/2) if n even, a(n) = 3n+1+a(3n+1) if n odd.
From Seiichi Manyama, Apr 25 2016: (Start)
This sequence was inspired by the Collatz problem (A006577).
The Collatz rule is as follows: If n is even, divide it by 2, otherwise multiply it by 3 and add 1 (A006370).
For example, starting with n = 3, one gets the sequence 3, 10, 5, 16, 8, 4, 2, 1. So a(3) = 10 + 5 + 16 + 8 + 4 + 2 + 1 = 46. (End) [Comment edited by N. J. A. Sloane, Apr 25 2016]

Crossrefs

Cf. A006370 (Collatz step), A006577 (trajectory length), A033493 (sum including n).

Programs

  • Maple
    A270814 := proc(n)
            local a, traj ;
            a := 0 ;
            traj := n ;
            while traj > 1 do
                    if type(traj, 'even') then
                            traj := traj/2 ;
                    else
                            traj := 3*traj+1 ;
                    end if;
                    a := a+traj ;
            end do:
            return a;
    end proc:
    [seq(A270814(n),n=1..60)];
  • PARI
    a(n) = my(ret=n-1); while((n>>=valuation(n,2)) > 1, ret+=5*n+2; n=3*n+1); ret; \\ Kevin Ryde, Dec 10 2022

Extensions

Typo in definition corrected by Gionata Neri, Apr 08 2016
Showing 1-2 of 2 results.