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-10 of 14 results. Next

A014682 The Collatz or 3x+1 function: a(n) = n/2 if n is even, otherwise (3n+1)/2.

Original entry on oeis.org

0, 2, 1, 5, 2, 8, 3, 11, 4, 14, 5, 17, 6, 20, 7, 23, 8, 26, 9, 29, 10, 32, 11, 35, 12, 38, 13, 41, 14, 44, 15, 47, 16, 50, 17, 53, 18, 56, 19, 59, 20, 62, 21, 65, 22, 68, 23, 71, 24, 74, 25, 77, 26, 80, 27, 83, 28, 86, 29, 89, 30, 92, 31, 95, 32, 98, 33, 101, 34, 104
Offset: 0

Views

Author

Keywords

Comments

This is the function usually denoted by T(n) in the literature on the 3x+1 problem. See A006370 for further references and links.
Intertwining of sequence A016789 '2,5,8,11,... ("add 3")' and the nonnegative integers.
a(n) = log_2(A076936(n)). - Amarnath Murthy, Oct 19 2002
The average value of a(0), ..., a(n-1) is A004526(n). - Amarnath Murthy, Oct 19 2002
Partial sums are A093353. - Paul Barry, Mar 31 2008
Absolute first differences are essentially in A014681 and A103889. - R. J. Mathar, Apr 05 2008
Only terms of A016789 occur twice, at positions given by sequences A005408 (odd numbers) and A016957 (6n+4): (1,4), (3,10), (5,16), (7,22), ... - Antti Karttunen, Jul 28 2017
a(n) represents the unique congruence class modulo 2n+1 that is represented an odd number of times in any 2n+1 consecutive oblong numbers (A002378). This property relates to Jim Singh's 2018 formula, as n^2 + n is a relevant oblong number. - Peter Munn, Jan 29 2022

Examples

			a(3) = -3*(-1) - 2*1 - 1*(-1) - 0*1 + 1*(-1) + 2*1 + 3*(-1) + 4*1 + 5*(-1) + 6*1 = 5. - _Bruno Berselli_, Dec 14 2015
		

References

  • J. C. Lagarias, ed., The Ultimate Challenge: The 3x+1 Problem, Amer. Math. Soc., 2010.

Crossrefs

Programs

  • Haskell
    a014682 n = if r > 0 then div (3 * n + 1) 2 else n'
                where (n', r) = divMod n 2
    -- Reinhard Zumkeller, Oct 03 2014
    
  • Magma
    [IsOdd(n) select (3*n+1)/2 else n/2: n in [0..52]]; // Vincenzo Librandi, Sep 28 2018
  • Maple
    T:=proc(n) if n mod 2 = 0 then n/2 else (3*n+1)/2; fi; end; # N. J. A. Sloane, Jan 31 2011
    A076936 := proc(n) option remember ; local apr,ifr,me,i,a ; if n <=2 then n^2 ; else apr := mul(A076936(i),i=1..n-1) ; ifr := ifactors(apr)[2] ; me := -1 ; for i from 1 to nops(ifr) do me := max(me, op(2,op(i,ifr))) ; od ; me := me+ n-(me mod n) ; a := 1 ; for i from 1 to nops(ifr) do a := a*op(1,op(i,ifr))^(me-op(2,op(i,ifr))) ; od ; if a = A076936(n-1) then me := me+n ; a := 1 ; for i from 1 to nops(ifr) do a := a*op(1,op(i,ifr))^(me-op(2,op(i,ifr))) ; od ; fi ; RETURN(a) ; fi ; end: A014682 := proc(n) log[2](A076936(n)) ; end: for n from 1 to 85 do printf("%d, ",A014682(n)) ; od ; # R. J. Mathar, Mar 20 2007
  • Mathematica
    Collatz[n_?OddQ] := (3n + 1)/2; Collatz[n_?EvenQ] := n/2; Table[Collatz[n], {n, 0, 79}] (* Alonso del Arte, Apr 21 2011 *)
    LinearRecurrence[{0, 2, 0, -1}, {0, 2, 1, 5}, 70] (* Jean-François Alcover, Sep 23 2017 *)
    Table[If[OddQ[n], (3 n + 1) / 2, n / 2], {n, 0, 60}] (* Vincenzo Librandi, Sep 28 2018 *)
  • PARI
    a(n)=if(n%2,3*n+1,n)/2 \\ Charles R Greathouse IV, Sep 02 2015
    
  • PARI
    a(n)=if(n<2,2*n,(n^2-n-1)%(2*n+1)) \\ Jim Singh, Sep 28 2018
    
  • Python
    def a(n): return n//2 if n%2==0 else (3*n + 1)//2
    print([a(n) for n in range(101)]) # Indranil Ghosh, Jul 29 2017
    

Formula

From Paul Barry, Mar 31 2008: (Start)
G.f.: x*(2 + x + x^2)/(1-x^2)^2.
a(n) = (4*n+1)/4 - (2*n+1)*(-1)^n/4. (End)
a(n) = -a(n-1) + a(n-2) + a(n-3) + 4. - John W. Layman
For n > 1 this is the image of n under the modified "3x+1" map (cf. A006370): n -> n/2 if n is even, n -> (3*n+1)/2 if n is odd. - Benoit Cloitre, May 12 2002
O.g.f.: x*(2+x+x^2)/((-1+x)^2*(1+x)^2). - R. J. Mathar, Apr 05 2008
a(n) = 5/4 + (1/2)*((-1)^n)*n + (3/4)*(-1)^n + n. - Alexander R. Povolotsky, Apr 05 2008
a(n) = Sum_{i=-n..2*n} i*(-1)^i. - Bruno Berselli, Dec 14 2015
a(n) = Sum_{k=0..n-1} Sum_{i=0..k} C(i,k) + (-1)^k. - Wesley Ivan Hurt, Sep 20 2017
a(n) = (n^2-n-1) mod (2*n+1) for n > 1. - Jim Singh, Sep 26 2018
The above formula can be rewritten to show a pattern: a(n) = (n*(n+1)) mod (n+(n+1)). - Peter Munn, Jan 29 2022
Binary: a(n) = (n shift left (n AND 1)) - (n shift right 1) = A109043(n) - A004526(n). - Rudi B. Stranden, Jun 15 2021
From Rudi B. Stranden, Mar 21 2022: (Start)
a(n) = A064455(n+1) - 1, relating the number ON cells in row n of cellular automaton rule 54.
a(n) = 2*n - A071045(n).
(End)
E.g.f.: (1 + x)*sinh(x)/2 + 3*x*cosh(x)/2 = ((4*x+1)*e^x + (2*x-1)*e^(-x))/4. - Rénald Simonetto, Oct 20 2022
a(n) = n*(n mod 2) + ceiling(n/2) = A193356(n) + A008619(n+1). - Jonathan Shadrach Gilbert, Mar 12 2023
a(n) = 2*a(n-2) - a(n-4) for n > 3. - Chai Wah Wu, Apr 17 2024

Extensions

Edited by N. J. A. Sloane, Apr 26 2008, at the suggestion of Artur Jasinski
Edited by N. J. A. Sloane, Jan 31 2011

A020914 Number of digits in the base-2 representation of 3^n.

Original entry on oeis.org

1, 2, 4, 5, 7, 8, 10, 12, 13, 15, 16, 18, 20, 21, 23, 24, 26, 27, 29, 31, 32, 34, 35, 37, 39, 40, 42, 43, 45, 46, 48, 50, 51, 53, 54, 56, 58, 59, 61, 62, 64, 65, 67, 69, 70, 72, 73, 75, 77, 78, 80, 81, 83, 85, 86, 88, 89, 91, 92, 94, 96, 97, 99, 100, 102, 104, 105, 107
Offset: 0

Views

Author

Keywords

Comments

Also, numbers k such that the first digit in the ternary expansion of 2^k is 1. - Mohammed Bouayoun (Mohammed.bouayoun(AT)sanef.com), Apr 24 2006
a(n) is the smallest integer such that n/a(n) < log_2(3). - Trevor G. Hyde (thyde12(AT)amherst.edu), Jul 31 2008
This sequence represents allowable values of the "dropping time" in the Collatz (3x+1) problem when iterated according to the function f(n) := n/2 if n is even, (3n+1)/2 otherwise, as tabulated in A126241. There is one exception, A126241(1), which has been set to zero by convention. - K. Spage, Oct 22 2009
An integer k is a term of A020914 if and only if floor(k*(1 + log(2)/log(3))) - abs(k-1)*(1 + log(2)/log(3)) - 1 >= 0. - K. Spage, Oct 22 2009
Also smallest k such that ceiling(2^k / 3^n) = 2. - Michel Lagneau, Jan 31 2012
For n > 0, first differences of A022330. - Michel Marcus, Oct 03 2013
Also the number of powers of two less than or equal to 3^n. - Robert G. Wilson v, May 25 2014
Except for 1, A020914 is the complement of A054414 and therefore these two form a pair of Beatty sequences. - Robert G. Wilson v, May 25 2014

Crossrefs

Cf. A056576, A054414, A070939, A000244, A227048, A022330, A022921 (first differences), A126241.
Cf. A020857 (decimal expansion of log_2(3)).
Cf. A020915.
Cf. A204399 (essentially the same).

Programs

Formula

a(n) = floor(1 + n*log(3)/log(2)). - K. Spage, Oct 22 2009
a(0) = 1, a(n+1) = a(n) + A022921(n). - K. Spage, Oct 23 2009
a(n) = A122437(n-1) - n. - K. Spage, Oct 23 2009
A098294(n) = a(n) + n for n > 0. - Mike Winkler, Dec 31 2010
a(n) = A070939(A000244(n)) = length of n-th row in triangle A227048. - Reinhard Zumkeller, Jun 30 2013
a(n) = 1 + floor(n*log_2(3)) = 1 + A056576(n) = 1 + floor(n*A020857). - L. Edson Jeffery, Dec 12 2014
A020915(a(n)) = n + 1. - Reinhard Zumkeller, Mar 28 2015

Extensions

More terms from Stefan Steinerberger, Apr 19 2006

A060412 In the '3x+1' problem, these values for the starting value set new records for the "dropping time", number of steps to reach a lower value than the start.

Original entry on oeis.org

2, 3, 7, 27, 703, 10087, 35655, 270271, 362343, 381727, 626331, 1027431, 1126015, 8088063, 13421671, 20638335, 26716671, 56924955, 63728127, 217740015, 1200991791, 1827397567, 2788008987, 12235060455
Offset: 1

Views

Author

N. J. A. Sloane, Apr 06 2001; b-file added Nov 27 2007

Keywords

Comments

The (3x+1)/2 steps and the halving steps are counted. - Don Reble, May 13 2006
Where records occur in A102419 (could be prefixed by an initial 1). - N. J. A. Sloane, Oct 20 2012

Examples

			See A102419.
		

Crossrefs

A060413 gives associated "dropping times", A060414 the maximal values and A060415 the steps at which the maxima occur. See also A217934.

Programs

  • Mathematica
    dcoll[n_]:=Length[NestWhileList[If[EvenQ[#],#/2,3#+1]&,n,#>=n&]]; t={max=2}; Do[If[(y=dcoll[n])>max,max=y; AppendTo[t,n]],{n,3,1130000,4}]; t (* Jayanta Basu, May 28 2013 *)

A102419 "Dropping time" in 3x+1 problem starting at n (number of steps to reach a lower number than starting value); a(1) = 0 by convention. Also called glide(n).

Original entry on oeis.org

0, 1, 6, 1, 3, 1, 11, 1, 3, 1, 8, 1, 3, 1, 11, 1, 3, 1, 6, 1, 3, 1, 8, 1, 3, 1, 96, 1, 3, 1, 91, 1, 3, 1, 6, 1, 3, 1, 13, 1, 3, 1, 8, 1, 3, 1, 88, 1, 3, 1, 6, 1, 3, 1, 8, 1, 3, 1, 11, 1, 3, 1, 88, 1, 3, 1, 6, 1, 3, 1, 83, 1, 3, 1, 8, 1, 3, 1, 13, 1, 3, 1, 6, 1, 3, 1, 8, 1, 3, 1, 73, 1, 3, 1, 13, 1, 3, 1, 6
Offset: 1

Views

Author

N. J. A. Sloane, Sep 15 2006

Keywords

Examples

			1: 0 steps
2 1: 1 step
3 10 5 16 8 4 2 1: 6 steps (before it drops below n)
4 2 1: 1 step
5 16 8 4 2 1: 3 steps
6 3 ...: 1 step
7 22 11 34 17 52 26 13 40 20 10 5 ...: 11 steps
...
Records: 0.1.6.11.96.132...171... (A217934)
at.......1.2.3..7.27.703.10087... (A060412)
		

Crossrefs

For records see A060412, A217934. - N. J. A. Sloane, Oct 20 2012

Programs

  • Mathematica
    Prepend[Table[Length[NestWhileList[If[EvenQ[#],#/2,3#+1]&,n,#>=n&]],{n,2,99}],1]-1 (* Jayanta Basu, May 28 2013 *)
  • Python
    def a(n):
        if n<3: return n - 1
        N=n
        x=0
        while True:
            if n%2==0: n//=2
            else: n = 3*n + 1
            x+=1
            if nIndranil Ghosh, Apr 22 2017

Formula

a(2n) = 1; a(2n+1) = A060445(n).
a(n) = A074473(n)-1 for n>1.
a(n) = floor(A126241(n)*(1+log(2)/log(3))). - K. Spage, Oct 22 2009

A060413 In the '3x+1' problem, take the sequence of starting values which set new records for the "dropping time" (A060412); sequence gives associated dropping times.

Original entry on oeis.org

1, 4, 7, 59, 81, 105, 135, 164, 165, 173, 176, 183, 224, 246, 287, 292, 298, 308, 376, 395, 398, 433, 447, 547, 550, 606, 688, 712, 722, 728, 886, 902, 966, 990, 1005
Offset: 1

Views

Author

N. J. A. Sloane, Apr 06 2001; b-file added Nov 27 2007

Keywords

Crossrefs

A186107 Numerator of the frequency of the n-th dropping time in the Collatz iteration.

Original entry on oeis.org

1, 1, 1, 1, 3, 7, 3, 15, 85, 173, 119, 961, 663, 8045, 17637, 51033, 54475, 312455, 663535, 950235, 5936673, 1684037, 39993895, 87986917, 128989251, 205059181, 949737339, 2861515293, 400296173, 19018424205
Offset: 1

Views

Author

T. D. Noe, Feb 12 2011

Keywords

Comments

The possible dropping times are in A020914. The denominators are in A186108. The cumulative frequency of the dropping time is A186109(n)/A186110(n).

Examples

			The frequencies are 1/2, 1/4, 1/16, 1/16, 3/128, 7/256, 3/256, 15/2048, 85/8192,....
		

Crossrefs

Cf. A126241 (dropping times)

Formula

a(n) = numerator of A186009(n) / 2^A020914(n-1).

A186108 Denominator of the frequency of the n-th dropping time in the Collatz iteration.

Original entry on oeis.org

2, 4, 16, 16, 128, 256, 256, 2048, 8192, 32768, 16384, 262144, 262144, 2097152, 8388608, 16777216, 33554432, 134217728, 536870912, 1073741824, 4294967296, 2147483648, 34359738368, 137438953472, 274877906944, 274877906944, 2199023255552, 4398046511104, 1099511627776, 35184372088832
Offset: 1

Views

Author

T. D. Noe, Feb 12 2011

Keywords

Comments

The numerators are in A186107.

Crossrefs

Cf. A126241 (dropping times)

Formula

a(n) = denominator of A186009(n) / 2^A020914(n-1).

A186109 Numerator of the cumulative frequency of the dropping time in the Collatz iteration.

Original entry on oeis.org

1, 3, 13, 7, 115, 237, 15, 1935, 7825, 31473, 31711, 254649, 15957, 2050541, 8219801, 16490635, 33035745, 132455435, 530485275, 1061920785, 4253619813, 4256987887, 34095896991, 136471574881, 273072139013, 136638599097, 2187167322891, 4377196161075, 4378797345767, 35049397190341
Offset: 1

Views

Author

T. D. Noe, Feb 12 2011

Keywords

Comments

The possible dropping times are in A020914. The denominators are in A186110. The frequency of the n-th dropping time is A186107(n)/A186108(n).
Riho Terras' classic paper about the Collatz problem shows the decimal values of 2(1-c(k)) in Table A, where c(k) is the cumulative frequency of dropping times <= k.

Examples

			The cumulative frequencies are 1/2, 3/4, 13/16, 7/8, 115/128, 237/256, 15/16, 1935/2048, 7825/8192, ... .
		

Crossrefs

Cf. A126241 (dropping times).

Formula

a(n) = numerator of Sum_{k=1..n} A186009(k) / 2^A020914(k-1).

A186008 Irregular triangle T(n,k) read by rows, in which row n has the pattern of conjectured dropping times in the Collatz iteration.

Original entry on oeis.org

2, 4, 16, 12, 32, 8, 52, 128, 40, 56, 84, 136, 160, 180, 256, 60, 80, 136, 220, 288, 296, 448, 528, 636, 688, 712, 1024, 152, 232, 384, 648, 704, 788, 856, 1000, 1204, 1416, 1472, 1556, 1592, 1624, 1800, 1972, 2008, 2120, 2356, 2360, 2676, 2744, 2888, 2912, 3064, 3328, 3444, 3680, 3832, 4096
Offset: 1

Views

Author

T. D. Noe, Feb 09 2011

Keywords

Comments

Consider A126241, the sequence of dropping times in the Collatz iteration. Only zero and the numbers in A020914 can be dropping times. The dropping times in A126241 have a definite pattern. For example, 1 appears at positions n = 2 + 2*i, for i=0,1,2,3,... Similarly, 2 appears at positions n = 5 + 4*i; 4 appears at n = 3 + 16*i; 5 appears at n = 11 + {12,32}*i; and 7 appears at 7 + {8, 52, 128}*i. In general, if we let s=A020914(r) be the r-th possible stopping time, then A126241(n) = s for n = A122442(r) + T(r)*i, where T(r) is the r-th row of this triangle. The length of row n is A186009(n). The n-th row ends with 2^A020914(n).
The frequency of the r-th dropping time s=A020914(r) can be computed as A186009(r)/2^s. The first few frequencies are 1/2, 1/4, 1/16, 1/16, 3/128, 7/256, 3/256, 15/2048, and 85/8192.
The term "stopping time" is sometimes used instead of "dropping time", but the former usually refers to A006666.
This sequence is closely related to A177789.

Examples

			The triangle begins
2
4
16
12, 32
8, 52, 128
40, 56, 84, 136, 160, 180, 256
60, 80, 136, 220, 288, 296, 448, 528, 636, 688, 712, 1024
		

References

  • J. C. Lagarias, ed., The Ultimate Challenge: The 3x+1 Problem, Amer. Math. Soc., 2010. See pp. 33, 35ff.

Crossrefs

A186110 Denominator of the cumulative frequency of the dropping time in the Collatz iteration.

Original entry on oeis.org

2, 4, 16, 8, 128, 256, 16, 2048, 8192, 32768, 32768, 262144, 16384, 2097152, 8388608, 16777216, 33554432, 134217728, 536870912, 1073741824, 4294967296, 4294967296, 34359738368, 137438953472, 274877906944, 137438953472, 2199023255552, 4398046511104, 4398046511104, 35184372088832
Offset: 1

Views

Author

T. D. Noe, Feb 12 2011

Keywords

Comments

The numerators are in A186109. The frequency of the n-th dropping time is A186107(n)/A186108(n).

Crossrefs

Cf. A126241 (dropping times)

Formula

a(n) = denominator of sum_{k=1..n} A186009(k) / 2^A020914(k-1).
Showing 1-10 of 14 results. Next