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

A070168 Irregular triangle of Terras-modified Collatz problem.

Original entry on oeis.org

1, 2, 1, 3, 5, 8, 4, 2, 1, 4, 2, 1, 5, 8, 4, 2, 1, 6, 3, 5, 8, 4, 2, 1, 7, 11, 17, 26, 13, 20, 10, 5, 8, 4, 2, 1, 8, 4, 2, 1, 9, 14, 7, 11, 17, 26, 13, 20, 10, 5, 8, 4, 2, 1, 10, 5, 8, 4, 2, 1, 11, 17, 26, 13, 20, 10, 5, 8, 4, 2, 1, 12, 6, 3, 5, 8, 4, 2, 1, 13, 20, 10, 5, 8, 4, 2, 1, 14, 7, 11
Offset: 1

Views

Author

Eric W. Weisstein, Apr 23 2002

Keywords

Comments

The row length of this irregular triangle is A006666(n) + 1 = A064433(n+1), n >= 1. - Wolfdieter Lang, Mar 20 2014

Examples

			The irregular triangle begins:
n\k   0   1   2   3   4   5   6   8  9 10  11  12  13  14 ...
1:    1
2:    2   1
3:    3   5   8   4   2   1
4:    4   2   1
5:    5   8   4   2   1
6:    6   3   5   8   4   2   1
7:    7  11  17  26  13  20  10   5  8  4   2   1
8:    8   4   2   1
9:    9  14   7  11  17  26  13  20 10  5   8   4   2   1
10:  10   5   8   4   2   1
11:  11  17  26  13  20  10   5   8  4  2   1
12:  12   6   3   5   8   4   2   1
13:  13  20  10   5   8   4   2   1
14:  14   7  11  17  26  13  20  10  5  8   4   2   1
15:  15  23  35  53  80  40  20  10  5  8   4   2   1
...  formatted by _Wolfdieter Lang_, Mar 20 2014
-------------------------------------------------------------
		

Crossrefs

Cf. A070165 (ordinary Collatz case).
Cf. A014682, A248573, A285098 (row sums).

Programs

  • Haskell
    a070168 n k = a070168_tabf !! (n-1) !! (k-1)
    a070168_tabf = map a070168_row [1..]
    a070168_row n = (takeWhile (/= 1) $ iterate a014682 n) ++ [1]
    a070168_list = concat a070168_tabf
    -- Reinhard Zumkeller, Oct 03 2014
    
  • Mathematica
    f[n_] := If[EvenQ[n], n/2, (3 n + 1)/2];
    Table[NestWhileList[f, n, # != 1 &], {n, 1, 30}] // Grid (* Geoffrey Critzer, Oct 18 2014 *)
  • Python
    def a(n):
        if n==1: return [1]
        l=[n, ]
        while True:
            if n%2==0: n//=2
            else: n = (3*n + 1)//2
            l.append(n)
            if n<2: break
        return l
    for n in range(1, 16): print(a(n)) # Indranil Ghosh, Apr 15 2017

Formula

From Wolfdieter Lang, Mar 20 2014: (Start)
See Lagarias, pp. 4-7, eqs. (2.1), (2.4) with (2.5) and (2.6).
T(n,k) = T^{(k)}(n), with the iterations of the Terras-modified Collatz map: T(n) = n/2 if n is even and otherwise (3*n+1)/2, n >= 1. T^{(0)}(n) = n.
T(n,k) = lambda(n,k)*n + rho(n,k), with lambda(n,k) = (3^X(n,k,-1))/2^k and rho(n,k) = sum(x(n,j)*(3^X(n,k,j))/ 2^(k-j), j=0..(k-1)) with X(n,k,j) = sum(x(n,j+p), p=1.. (k-1-j)) where x(n,j) = T^{(j)}(n) (mod 2). The parity sequence suffices to determine T(n,k).
(End)

Extensions

Name shortened, tabl changed into tabf, Cf. added by Wolfdieter Lang, Mar 20 2014

A351850 a(n) is the number of iterations of the computation of the A351849 tag system when started from the word encoding n, or -1 if the number of iterations is infinite.

Original entry on oeis.org

0, 2, 24, 6, 20, 30, 128, 14, 152, 30, 120, 42, 64, 142, 300, 30, 108, 170, 236, 50, 84, 142, 284, 66, 300, 90, 40656, 170, 216, 330, 40524, 62, 384, 142, 260, 206, 264, 274, 996, 90, 40628, 126, 596, 186, 256, 330, 40492, 114, 388, 350, 520, 142, 224, 40710
Offset: 1

Views

Author

Paolo Xausa, Feb 22 2022

Keywords

Comments

If x is even, the A351849 tag system evolves from the word encoding x to the word encoding x/2 in x iterations; if x is odd, x+1 iterations are required to produce the word encoding (3x+1)/2.
See A351849 for additional comments, links and examples.

Examples

			When started from 1111 (the word encoding the number 4), the system evolves as 1111 -> 1123 -> 2323 -> 231 -> 11 -> 23 -> 1, reaching the word 1 after 6 steps. a(4) is therefore 6.
		

Crossrefs

Programs

  • Mathematica
    (* First program, based on the tag system definition *)
    t[s_]:=StringDrop[s,2]<>StringReplace[StringTake[s,1],{"1"->"23","2"->"1","3"->"111"}];
    nterms=100;Table[Length[NestWhileList[t,StringRepeat["1",n],#!="1"&]]-1,{n,nterms}]
    (* Second program, more efficient, based on formula *)
    c[x_]:=If[OddQ[x],(3x+1)/2,x/2];
    nterms=100;Table[Total[Map[If[OddQ[#],#+1,#]&,NestWhileList[c,n,#>1&]]]-2,{n,nterms}]
  • Python
    def A351850(n):
        s, steps = "1" * n, 0
        while s != "1":
            if s[0] == "1": s += "23"
            elif s[0] == "2": s += "1"
            else: s += "111"
            s = s[2:]
            steps += 1
        return steps
    nterms = 100
    print([A351850(n) for n in range(1, nterms + 1)])

Formula

a(n) = (Sum_{k=0..A006666(n)} 2*floor((A070168(n,k)+1)/2)) - 2.

A375268 Row sums of A375266.

Original entry on oeis.org

1, 3, 4, 7, 36, 9, 288, 15, 13, 46, 259, 19, 119, 302, 51, 31, 214, 27, 519, 66, 309, 281, 633, 39, 658, 145, 40, 330, 442, 76, 101104, 63, 292, 248, 540, 55, 535, 557, 158, 106, 101331, 344, 1338, 325, 96, 679, 100979, 79, 806, 708, 265, 197, 399, 81, 102316, 386
Offset: 1

Views

Author

Paolo Xausa, Aug 09 2024

Keywords

Crossrefs

Programs

  • Mathematica
    A375265[n_] := Which[Divisible[n, 3], n/3, Divisible[n, 2], n/2, True, 3*n + 1];
    Array[Total[NestWhileList[A375265, #, # > 1 &]] &, 100]

Formula

a(n) = Sum_{k = 1..A375267(n) + 1} A375266(n,k).

A375910 Row sums of A350279.

Original entry on oeis.org

1, 4, 9, 48, 13, 41, 61, 24, 30, 72, 69, 151, 86, 40, 53, 538, 74, 128, 109, 100, 110, 182, 69, 507, 135, 81, 93, 395, 129, 217, 599, 132, 139, 249, 220, 460, 182, 161, 177, 850, 121, 340, 267, 140, 158, 448, 631, 1625, 232, 173, 182, 708, 233, 389, 504, 220, 242, 428
Offset: 1

Views

Author

Paolo Xausa, Sep 02 2024

Keywords

Comments

1

Crossrefs

Programs

  • Mathematica
    FarkasStep[x_] := Which[Divisible[x, 3], x/3, Mod[x, 4] == 3, (3*x + 1)/2, True, (x + 1)/2];
    Array[Total[FixedPointList[FarkasStep, 2*# - 1]] - 1 &, 100]

Formula

a(n) = Sum_{k = 1..A375909(n) + 1} A350279(n,k).
Showing 1-4 of 4 results.