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

A007494 Numbers that are congruent to 0 or 2 mod 3.

Original entry on oeis.org

0, 2, 3, 5, 6, 8, 9, 11, 12, 14, 15, 17, 18, 20, 21, 23, 24, 26, 27, 29, 30, 32, 33, 35, 36, 38, 39, 41, 42, 44, 45, 47, 48, 50, 51, 53, 54, 56, 57, 59, 60, 62, 63, 65, 66, 68, 69, 71, 72, 74, 75, 77, 78, 80, 81, 83, 84, 86, 87, 89, 90, 92, 93, 95, 96, 98, 99, 101, 102, 104, 105, 107
Offset: 0

Views

Author

Christopher Lam Cham Kee (Topher(AT)CyberDude.Com)

Keywords

Comments

The map n -> a(n) (where a(n) = 3n/2 if n even or (3n+1)/2 if n odd) was studied by Mahler, in connection with "Z-numbers" and later by Flatto. One question was whether, iterating from an initial integer, one eventually encountered an iterate = 1 (mod 4). - Jeff Lagarias, Sep 23 2002
Partial sums of 0,2,1,2,1,2,1,2,1,... . - Paul Barry, Aug 18 2007
a(n) = numbers k such that antiharmonic mean of the first k positive integers is not integer. A169609(a(n-1)) = 3. See A146535 and A169609. Complement of A016777. - Jaroslav Krizek, May 28 2010
Range of A173732. - Reinhard Zumkeller, Apr 29 2012
Number of partitions of 6n into two odd parts. - Wesley Ivan Hurt, Nov 15 2014
Numbers m such that 3 divides A000217(m). - Bruno Berselli, Aug 04 2017
Maximal length of a snake like polyomino that fits in a 2 X n rectangle. - Alain Goupil, Feb 12 2020

References

  • L. Flatto, Z-numbers and beta-transformations, in Symbolic dynamics and its applications (New Haven, CT, 1991), 181-201, Contemp. Math., 135, Amer. Math. Soc., Providence, RI, 1992.

Crossrefs

Complement of A016777.
Range of A002517.
Cf. A274406. [Bruno Berselli, Jun 26 2016]

Programs

Formula

a(n) = 3*n/2 if n even, otherwise (3*n+1)/2.
If u(1)=0, u(n) = n + floor(u(n-1)/3), then a(n-1) = u(n). - Benoit Cloitre, Nov 26 2002
G.f.: x*(x+2)/((1-x)^2*(1+x)). - Ralf Stephan, Apr 13 2002
a(n) = 3*floor(n/2) + 2*(n mod 2) = A032766(n) + A000035(n). - Reinhard Zumkeller, Apr 04 2005
a(n) = (6*n+1)/4 - (-1)^n/4; a(n) = Sum_{k=0..n-1} (1 + (-1)^(k/2)*cos(k*Pi/2)). - Paul Barry, Aug 18 2007
A145389(a(n)) <> 1. - Reinhard Zumkeller, Oct 10 2008
a(n) = A002943(n) - A173511(n). - Reinhard Zumkeller, Feb 20 2010
a(n) = 3*n - a(n-1) - 1 (with a(0)=0). - Vincenzo Librandi, Nov 18 2010
a(n) = Sum_{k>=0} A030308(n,k)*A042950(k). - Philippe Deléham, Oct 17 2011
a(n) = n + ceiling(n/2). - Arkadiusz Wesolowski, Sep 18 2012
a(n) = 2n - floor(n/2) = floor((3n+1)/2) = n + (n + (n mod 2))/2. - Wesley Ivan Hurt, Oct 19 2013
a(n) = A000217(n+1) - A099392(n+1). - Bui Quang Tuan, Mar 27 2015
a(n) = n + floor(n/2) + (n mod 2). - Bruno Berselli, Apr 04 2016
a(n) = Sum_{i=1..n} numerator(2/i). - Wesley Ivan Hurt, Feb 26 2017
a(n) = Sum_{k=0..n-1} Sum_{i=0..k} C(i,k)+(-1)^(k-i). - Wesley Ivan Hurt, Sep 20 2017
E.g.f.: (3*exp(x)*x + sinh(x))/2. - Stefano Spezia, Feb 11 2020
Sum_{n>=1} (-1)^(n+1)/a(n) = log(3)/2 - Pi/(6*sqrt(3)). - Amiram Eldar, Dec 04 2021

A020988 a(n) = (2/3)*(4^n-1).

Original entry on oeis.org

0, 2, 10, 42, 170, 682, 2730, 10922, 43690, 174762, 699050, 2796202, 11184810, 44739242, 178956970, 715827882, 2863311530, 11453246122, 45812984490, 183251937962, 733007751850, 2932031007402, 11728124029610, 46912496118442, 187649984473770, 750599937895082
Offset: 0

Views

Author

Keywords

Comments

Numbers whose binary representation is 10, n times (see A163662(n) for n >= 1). - Alexandre Wajnberg, May 31 2005
Numbers whose base-4 representation consists entirely of 2's; twice base-4 repunits. - Franklin T. Adams-Watters, Mar 29 2006
Expected time to finish a random Tower of Hanoi problem with 2n disks using optimal moves, so (since 2n is even and A010684(2n) = 1) a(n) = A060590(2n). - Henry Bottomley, Apr 05 2001
a(n) is the number of derangements of [2n + 3] with runs consisting of consecutive integers. E.g., a(1) = 10 because the derangements of {1, 2, 3, 4, 5} with runs consisting of consecutive integers are 5|1234, 45|123, 345|12, 2345|1, 5|4|123, 5|34|12, 45|23|1, 345|2|1, 5|4|23|1, 5|34|2|1 (the bars delimit the runs). - Emeric Deutsch, May 26 2003
For n > 0, also smallest numbers having in binary representation exactly n + 1 maximal groups of consecutive zeros: A087120(n) = a(n-1), see A087116. - Reinhard Zumkeller, Aug 14 2003
Number of walks of length 2n + 3 between any two diametrically opposite vertices of the cycle graph C_6. Example: a(0) = 2 because in the cycle ABCDEF we have two walks of length 3 between A and D: ABCD and AFED. - Emeric Deutsch, Apr 01 2004
From Paul Barry, May 18 2003: (Start)
Row sums of triangle using cumulative sums of odd-indexed rows of Pascal's triangle (start with zeros for completeness):
0 0
1 1
1 4 4 1
1 6 14 14 6 1
1 8 27 49 49 27 8 1 (End)
a(n) gives the position of the n-th zero in A173732, i.e., A173732(a(n)) = 0 for all n and this gives all the zeros in A173732. - Howard A. Landman, Mar 14 2010
Smallest number having alternating bit sum -n. Cf. A065359. For n = 0, 1, ..., the last digit of a(n) is 0, 2, 0, 2, ... . - Washington Bomfim, Jan 22 2011
Number of toothpicks minus 1 in the toothpick structure of A139250 after 2^n stages. - Omar E. Pol, Mar 15 2012
For n > 0 also partial sums of the odd powers of 2 (A004171). - K. G. Stier, Nov 04 2013
Values of m such that binomial(4*m + 2, m) is odd. Cf. A002450. - Peter Bala, Oct 06 2015
For a(n) > 2, values of m such that m is two steps away from a power of 2 under the Collatz iteration. - Roderick MacPhee, Nov 10 2016
a(n) is the position of the first occurrence of 2^(n+1)-1 in A020986. See the Brillhart and Morton link, pp. 856-857. - John Keith, Jan 12 2021
a(n) is the number of monotone paths in the n-dimensional cross-polytope for a generic linear orientation. See the Black and De Loera link. - Alexander E. Black, Feb 15 2023

Crossrefs

Programs

Formula

a(n) = 4*a(n-1) + 2, a(0) = 0.
a(n) = A026644(2*n).
a(n) = A007583(n) - 1 = A039301(n+1) - 2 = A083584(n-1) + 1.
E.g.f. : (2/3)*(exp(4*x)-exp(x)). - Paul Barry, May 18 2003
a(n) = A007583(n+1) - 1 = A039301(n+2) - 2 = A083584(n) + 1. - Ralf Stephan, Jun 14 2003
G.f.: 2*x/((1-x)*(1-4*x)). - R. J. Mathar, Sep 17 2008
a(n) = a(n-1) + 2^(2n-1), a(0) = 0. - Washington Bomfim, Jan 22 2011
a(n) = A193652(2*n). - Reinhard Zumkeller, Aug 08 2011
a(n) = 5*a(n-1) - 4*a(n-2) (n > 1), a(0) = 0, a(1) = 2. - L. Edson Jeffery, Mar 02 2012
a(n) = (2/3)*A024036(n). - Omar E. Pol, Mar 15 2012
a(n) = 2*A002450(n). - Yosu Yurramendi, Jan 24 2017
From Seiichi Manyama, Nov 24 2017: (Start)
Zeta_{GL(2)/F_1}(s) = Product_{k = 1..4} (s-k)^(-b(2,k)), where Sum b(2,k)*t^k = t*(t-1)*(t^2-1). That is Zeta_{GL(2)/F_1}(s) = (s-3)*(s-2)/((s-4)*(s-1)).
Zeta_{GL(2)/F_1}(s) = Product_{n > 0} (1 - (1/s)^n)^(-A295521(n)) = Product_{n > 0} (1 - x^n)^(-A295521(n)) = (1-3*x)*(1-2*x)/((1-4*x)*(1-x)) = 1 + Sum_{k > 0} a(k-1)*x^k (x=1/s). (End)
From Oboifeng Dira, May 29 2020: (Start)
a(n) = A078008(2n+1) (second bisection).
a(n) = Sum_{k=0..n} binomial(2n+1, ((n+2) mod 3)+3k). (End)
From John Reimer Morales, Aug 04 2025: (Start)
a(n) = A000302(n) - A047849(n).
a(n) = A020522(n) + A000079(n) - A047849(n). (End)

Extensions

Edited by N. J. A. Sloane, Sep 06 2006

A025480 a(2n) = n, a(2n+1) = a(n).

Original entry on oeis.org

0, 0, 1, 0, 2, 1, 3, 0, 4, 2, 5, 1, 6, 3, 7, 0, 8, 4, 9, 2, 10, 5, 11, 1, 12, 6, 13, 3, 14, 7, 15, 0, 16, 8, 17, 4, 18, 9, 19, 2, 20, 10, 21, 5, 22, 11, 23, 1, 24, 12, 25, 6, 26, 13, 27, 3, 28, 14, 29, 7, 30, 15, 31, 0, 32, 16, 33, 8, 34, 17, 35, 4, 36, 18, 37, 9, 38, 19, 39, 2, 40, 20, 41, 10
Offset: 0

Views

Author

Keywords

Comments

These are the Grundy values or nim-values for heaps of n beans in the game where you're allowed to take up to half of the beans in a heap. - R. K. Guy, Mar 30 2006. See Levine 2004/2006 for more about this. - N. J. A. Sloane, Aug 14 2016
When n > 0 is written as (2k+1)*2^j then k = a(n-1) and j = A007814(n), so: when n is written as (2k+1)*2^j-1 then k = a(n) and j = A007814(n+1), when n > 1 is written as (2k+1)*2^j+1 then k = a(n-2) and j = A007814(n-1). - Henry Bottomley, Mar 02 2000 [sequence id corrected by Peter Munn, Jun 22 2022]
According to the comment from Deuard Worthen (see Example section), this may be regarded as a triangle where row r=1,2,3,... has length 2^(r-1) and values T(r,2k-1)=T(r-1,k), T(r,2k)=2^(r-1)+k-1; i.e., previous row gives 1st, 3rd, 5th, ... term and 2nd, 4th, ... terms are numbers 2^(r-1),...,2^r-1 (i.e., those following the last one from the previous row). - M. F. Hasler, May 03 2008
Let StB be a Stern-Brocot tree hanging between (pseudo)fractions Left and Right, then StB(1) = mediant(Left,Right) and for n>1: StB(n) = if a(n-1)<>0 and a(n)<>0 then mediant(StB(a(n-1)),StB(a(n))) else if a(n)=0 then mediant(StB(a(n-1)),Right) else mediant(Left,StB(a(n-1))), where mediant(q1,q2) = ((numerator(q1)+numerator(q2)) / (denominator(q1)+denominator(q2))). - Reinhard Zumkeller, Dec 22 2008
This sequence is the unique fixed point of the function (a(0), a(1), a(2), ...) |--> (0, a(0), 1, a(1), 2, a(2), ...) which interleaves the nonnegative integers between the elements of a sequence. - Cale Gibbard (cgibbard(AT)gmail.com), Nov 18 2009
Also the number of remaining survivors in a Josephus problem after the person originally first in line has been eliminated (see A225381). - Marcus Hedbring, May 18 2013
A fractal sequence - see Levine 2004/2006. - N. J. A. Sloane, Aug 14 2016
From David James Sycamore, Apr 29 2020: (Start)
One of a family of fractal sequences, S_k; defined as follows for k >= 2: a(k*n) = n, a(k*n+r) = a((k-1)*n + (r-1)), r = 1..(k-1). S_2 is A025480; S_3 gives: a(3*n) = n, a(3*n + 1) = a(2*n), a(3*n + 2) = a(2*n + 1), which is A263390.
The subsequence of all nonzero terms is A131987. (End)
Similar to but different from A108202. - N. J. A. Sloane, Nov 26 2020
This sequence can be otherwise defined in two alternative (but related) ways, with a(0)=0, as follows: (i) If a(n) is a novel term, then a(n+1) = a(a(n)); if a(n) has been seen before, most recently at a(m), then a(n+1) = n-m (as in A181391). (ii) As above for novel a(n), then if a(n) has been seen before, a(n+1) = smallest k < a(n) which is not already a term. - David James Sycamore, Jul 13 2021
From a binary perspective, the sequence can be seen as even,odd pairs where the odd value is the previous even value, dropping the rightmost bits up to and including the lowest zero bit, aka right-shifted past the lowest clear bit. E.g., (5)101 -> 1, (17)10001 -> (4)100, (29)11101 -> (7)111, (39)100111 -> (2)10. - Joe Nellis, Oct 09 2022

Examples

			From Deuard Worthen (deuard(AT)raytheon.com), Jan 27 2006: (Start)
The sequence can be constructed as a triangle as:
  0
  0  1
  0  2  1  3
  0  4  2  5  1  6  3  7
  0  8  4  9  2 10  5 11  1 12  6 13  3 14  7 15
  ...
At each stage we interleave the next 2^m numbers in the previous row. (End)
Left=0/1, Right=1/0: StB=A007305/A047679; Left=0/1, Right=1/1: StB=A007305/A007306; Left=1/3, Right=2/3: StB=A153161/A153162. - _Reinhard Zumkeller_, Dec 22 2008
		

References

  • L. Levine, Fractal sequences and restricted Nim, Ars Combin. 80 (2006), 113-127.

Crossrefs

Programs

  • Haskell
    import Data.List
    interleave xs ys = concat . transpose $ [xs,ys]
    a025480 = interleave [0..] a025480
    -- Cale Gibbard, Nov 18 2009
    
  • Haskell
    Cf. comments by Worthen and Hasler.
    import Data.List (transpose)
    a025480 n k = a025480_tabf !! n !! k
    a025480_row n = a025480_tabf !! n
    a025480_tabf = iterate (\xs -> concat $
       transpose [xs, [length xs .. 2 * length xs - 1]]) [0]
    a025480_list = concat $ a025480_tabf
    -- Reinhard Zumkeller, Apr 29 2012
    
  • Maple
    A025480 := proc(n)
        option remember ;
        if type(n,'even') then
            n/2 ;
        else
            procname((n-1)/2) ;
        end if;
    end proc:
    seq(A025480(n),n=0..100) ; # R. J. Mathar, Jul 16 2020
  • Mathematica
    a[n_] := a[n] = If[OddQ@n, a[(n - 1)/2], n/2]; Table[ a[n], {n, 0, 83}] (* Robert G. Wilson v, Mar 30 2006 *)
    Table[BitShiftRight[n, IntegerExponent[n, 2] + 1], {n, 100}] (* IWABUCHI Yu(u)ki, Oct 13 2012 *)
  • PARI
    a(n)={while(n%2,n\=2);n\2} \\ M. F. Hasler, May 03 2008
    
  • PARI
    A025480(n)=n>>valuation(n*2+2,2) \\ M. F. Hasler, Apr 12 2012
    
  • Python
    def A025480(n): return n>>((~(n+1)&n).bit_length()+1) # Chai Wah Wu, Jul 13 2022
  • Sage
    A025480 = lambda n: odd_part(n+1)//2
    [A025480(n) for n in (0..83)] # Peter Luschny, May 20 2014
    

Formula

a(n) = A003602(n+1) - 1. [Corrected by Max Alekseyev, May 05 2022]
a(n) = (A000265(n+1)-1)/2 = ((n+1)/A006519(n+1)-1)/2.
a(n) = A153733(n)/2. - Reinhard Zumkeller, Dec 31 2008
2^A007814(n+1)*(2*a(n)+1) = n+1. (See functions hd, tl and cons in [Paul Tarau 2009].) - Paul Tarau (paul.tarau(AT)gmail.com), Mar 21 2010
a(3*n + 1) = A173732(n). - Reinhard Zumkeller, Apr 29 2012
a((2*n+1)*2^p-1) = n, p >= 0 and n >= 0. - Johannes W. Meijer, Jan 24 2013
a(n) = n - A225381(n). - Marcus Hedbring, May 18 2013
G.f.: -1/(1-x) + Sum_{k>=0} x^(2^k-1)/(1-2*x^2^(k+1)+x^2^(k+2)). - Ralf Stephan, May 19 2013
a(n) = A049084(A181363(n+1)). - Reinhard Zumkeller, Mar 22 2014
a(n) = floor(n / 2^A001511(n+1)). - Adam Shelly, Mar 05 2019
Recursion: a(0) = 0; a(n + 1) = a(a(n)) if a(n) is a first occurrence of a term, else a(n + 1) = n - a(n-1). - David James Sycamore, Apr 29 2020
a(n) * 2^(A007814(n+1)+1) + 2^A007814(n+1) - 1 = n (equivalent to the formula given in the comment by Paul Tarau). - Ruud H.G. van Tol, Apr 14 2023
Sum_{k=1..n} a(k) = n^2/6 + O(n). - Amiram Eldar, Aug 07 2023

Extensions

Edited by M. F. Hasler, Mar 16 2018

A075680 For odd numbers 2n-1, the minimum number of iterations of the reduced Collatz function R required to yield 1. The function R is defined as R(k) = (3k+1)/2^r, with r as large as possible.

Original entry on oeis.org

0, 2, 1, 5, 6, 4, 2, 5, 3, 6, 1, 4, 7, 41, 5, 39, 8, 3, 6, 11, 40, 9, 4, 38, 7, 7, 2, 41, 10, 10, 5, 39, 8, 8, 3, 37, 42, 3, 6, 11, 6, 40, 1, 9, 9, 33, 4, 38, 43, 7, 7, 31, 12, 36, 41, 24, 2, 10, 5, 10, 34, 15, 39, 15, 44, 8, 8, 13, 32, 13, 3, 37, 42, 42, 6, 3, 11, 30, 11, 18, 35, 6, 40, 23
Offset: 1

Views

Author

T. D. Noe, Sep 25 2002

Keywords

Comments

See A075677 for the function R applied to the odd numbers once. The 3x+1 conjecture asserts that a(n) is a finite number for all n. The function R applied to the odd numbers shows the essential behavior of the 3x+1 iterations.
Bisection of A006667. - T. D. Noe, Jun 01 2006

Examples

			a(4) = 5 because 7 is the fourth odd number and 5 iterations are needed: R(R(R(R(R(7)))))=1.
		

Crossrefs

Cf. A075677.
Cf. A075684 for the largest number attained during the iteration.
Cf. A000265.
Cf. A060445 which also counts intermediate even steps.
Cf. A173732.

Programs

  • Haskell
    a075680 n = snd $ until ((== 1) . fst)
                (\(x, i) -> (a000265 (3 * x + 1), i + 1)) (2 * n - 1, 0)
    -- Reinhard Zumkeller, Jan 08 2014
    
  • Mathematica
    nextOddK[n_] := Module[{m=3n+1}, While[EvenQ[m], m=m/2]; m]; (* assumes odd n *) Table[m=n; cnt=0; If[n>1, While[m=nextOddK[m]; cnt++; m!=1]]; cnt, {n, 1, 200, 2}]
  • PARI
    a(n)=my(s); n+=n-1; while(n>1, n+=n>>1+1; if(n%2==0, n>>=valuation(n,2)); s++); s \\ Charles R Greathouse IV, Dec 22 2021
  • Perl
    sub a {
      my $v = 2 * shift() - 1;
      my $c = 0;
      until (1 == $v) {
        $v = 3 * $v + 1;
        $v /= 2 until ($v & 1);
        $c += 1;
      }
      return $c;
    } # Ruud H.G. van Tol, Nov 16 2021
    

Formula

a(n) = a(A173732(n-1) + 1) + 1 for n >= 2. - Alan Michael Gómez Calderón, Apr 10 2025

A204418 Periodic sequence 1,0,1,..., arranged in a triangle.

Original entry on oeis.org

1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1
Offset: 0

Views

Author

Philippe Deléham, Jan 15 2012

Keywords

Comments

Binomial transform is A130781.
Row sums: 1, 1, 2, 3, 3, 4, 5, 5, 6, 7, 7, 8, 9, 9, ... = A004396(n+1) = A131737 (n+2) .
Diagonal sums: 1, 0, 2, 1, 1, 3, 3, 1, 5, 3, 2, 6, 5, 2, 8, 5, 3, 9, 7, 3, 11, 7, 4, 12, 9, 4, 14, 9, 5, 15, ..
Essentially the same as A141571 and A011655. - R. J. Mathar, Jan 16 2012
As sequence a(n) this is the characteristic sequence for the mod m reduced odd numbers (i.e., gcd(2*n+1,m)=1, n >= 0) for each modulus m from 3*A003586 = [3,6,9,12,18,24,27,36,48,...]. - Wolfdieter Lang, Feb 04 2012
Disregarding the triangle: a(A173732(n)) = 1. - Reinhard Zumkeller, Apr 29 2012

Examples

			Triangle begins:
  1;
  0, 1;
  1, 0, 1;
  1, 0, 1, 1;
  0, 1, 1, 0, 1;
  1, 0, 1, 1, 0, 1;
  1, 0, 1, 1, 0, 1, 1;
  0, 1, 1, 0, 1, 1, 0, 1;
  1, 0, 1, 1, 0, 1, 1, 0, 1;
		

References

  • Michel Rigo, Formal Languages, Automata and Numeration Systems, 2 vols., Wiley, 2014. Mentions this sequence - see "List of Sequences" in Vol. 2.

Crossrefs

Cf. A011655.

Programs

Formula

If k==0 mod(3), T(n+k,k) = 1, 0, 1, 1, 0, 1, 1, 0, 1, ... (A204418)
If k==1 mod(3), T(n+k,k) = 1, 0, 0, 1, 0, 0, 1, 0, 0, ... (A079978)
If n==2 mod(3), T(n+k,k) = 1, 1, 1, 1, 1, 1, 1, 1, 1, ... (A000012)
a(A016777(n)) = 0.
G.f.:(1+x^2)/(1-x^3).
G.f.: U(0) where U(k)= 1 + x^2/(1 - x/(x + 1/U(k+1))); (continued fraction, 3-step). - Sergei N. Gladkovskii, Oct 17 2012

A349414 a(n) = A324245(n) - n.

Original entry on oeis.org

0, 1, -2, 2, -1, 3, -5, 4, -2, 5, -8, 6, -3, 7, -11, 8, -4, 9, -14, 10, -5, 11, -17, 12, -6, 13, -20, 14, -7, 15, -23, 16, -8, 17, -26, 18, -9, 19, -29, 20, -10, 21, -32, 22, -11, 23, -35, 24, -12, 25, -38, 26, -13, 27, -41, 28, -14, 29, -44, 30, -15, 31, -47, 32
Offset: 0

Views

Author

Ruud H.G. van Tol, Nov 16 2021

Keywords

Comments

This uses a modified Collatz-Terras map, called f in the Vaillant and Delarue link. Odd k = 2*n+1; a(0) = 0 represents 1 "is done".
From Ruud H.G. van Tol, Dec 09 2021: (Start)
a(n) is given by cases according as r = n mod 4 is 0,1,2,3 so that the sequence can be taken as an array with row m = floor(n/4) and column r,
| 8m + 1 3 5 7 |
| m |r:0 1 2 3 |
+---+--------------+
| 0 | 0 1 -2 2 |
| 1 | -1 3 -5 4 |
| 2 | -2 5 -8 6 |
| 3 | -3 7 -11 8 |
...
All positive integers eventually reach 1 in the Collatz problem iff all nonnegative integers eventually reach 0 with repeated application of this map, i.e., if for all n, the sequence n, n+a(n), n+a(n+a(n)), n+a(n+a(n+a(n))), ... eventually hits 0 (by hitting any a(n) == -n).
Example for m = 1, r = 0: (8m+1) = 9; a(floor(9/2)) = a(4) = -1, which leads to (9 + 2*-1) = 7.
Notice that the "(8m+5) -> (8m+5-1) / 4 = (2k+1)" operation of the values for r == 2, is "shedding bits", similar to what division-by-2 does. Any trailing '101' of the odd is transformed to '1', so it is not performing a Collatz step itself, but it is "escaping the column".
a(n) = A246425(n) if r is in (0,1,3) (A047472). The values for r == 2 are (n' - n + a(n')), with n' derived as (n' = n; n' = floor(n' / 4) while (n' mod 4 == 2)). Example for 8m+5 == 53: n = (53 - 1) / 2 = 26; n' = ((26 -2)/4 -2)/4 = 1; A246425(26) = 1 - 26 + a(1) = -25 + 1 = -24.
(End)

Examples

			a(1) = 1 -> a(1+1) = -2 -> a(1+1-2) = a(0) = 0, which represents 3 -> 5 -> 1.
		

Crossrefs

Programs

  • Mathematica
    Table[(1 - 3 (-1)^n - 4 n (-1)^n + 2 (1 + n) Cos[n*Pi/2])/8, {n, 0, 100}] (* Wesley Ivan Hurt, Nov 16 2021 *)
    LinearRecurrence[{-1,-1,-1,1,1,1,1},{0,1,-2,2,-1,3,-5},64] (* Stefano Spezia, Nov 17 2021 *)
  • PARI
    A324245(n) = if(n%2, (1+3*n)/2, if(!(n%4), 3*(n/4), (n-2)/4));
    A349414(n) = (A324245(n)-n); \\ Antti Karttunen, Dec 09 2021

Formula

a(n) = A324245(n) - n.
a(n) = (n+1)/2 if n is odd,
a(n) = -1*n/4 if n == 0 (mod 4),
a(n) = (n-2)/4 - n if n == 2 (mod 4).
Let r = n mod 4 and m = n div 4.
r=0: a(n) = -1*m = a(n-4)-1
r=1: a(n) = 2*m+1 = a(n-4)+2 = a(n-2)+1
r=2: a(n) = -3*m-2 = a(n-4)-3
r=3: a(n) = 2*m+2 = a(n-4)+2 = a(n-2)+1
The moving sum over 4 elements gives the sequence /1,0,-2,-1/.
From Wesley Ivan Hurt, Nov 16 2021: (Start)
a(n) = (1 - 3*(-1)^n - 4*n*(-1)^n + 2*(1+n)*cos(n*Pi/2))/8.
G.f.: x*(1 - x + x^2 + x^4)/((1-x)*(1 + x + x^2 + x^3)^2). (End)
From Stefano Spezia, Nov 17 2021: (Start)
a(n) = - a(n-1) - a(n-2) - a(n-3) + a(n-4) + a(n-5) + a(n-6) + a(n-7) for n > 6.
E.g.f.: (cos(x) + (2*x - 1)*cosh(x) - x*sin(x) - 2*(x - 1)*sinh(x))/4. (End)
a(n) >= - n. - Ruud H.G. van Tol, Dec 09 2021

A345228 Square array T(m, n), read by ascending antidiagonals. Let f(k) = k/2 if k is even, otherwise ((2*n+1)*k + 2*T(m, n) + 1)/2, T(m, n) is the smallest integer greater than -1, where m = f^j(m) for j > 0 exists. f^j(m) means the j-th iterate of f(m).

Original entry on oeis.org

0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 2, 0, 3, 0, 0, 2, 2, 0, 2, 3, 1, 0, 2, 3, 0, 1, 2, 10, 0, 2, 1, 3, 0, 0, 1, 7, 3, 2, 1, 3, 4, 0, 7, 0, 4, 2, 17, 1, 3, 5, 4, 0, 6, 7, 1, 1, 4, 10, 3, 0, 4, 5, 0, 5, 6, 22, 0, 7, 7, 24, 4, 1, 2, 5, 0, 4, 5, 19, 7, 2, 4, 17, 3, 4, 2
Offset: 0

Views

Author

Thomas Scheuerle, Jun 11 2021

Keywords

Comments

This sequence is an extension of A344583 ( row T(m, 1) ).
From Thomas Scheuerle, Dec 11 2023: (Start)
It was formerly stated that "T(m, n) >= T(1, n) if m > 0". This was wrong and did not consider an important condition which could lead to exceptions. It is interesting that this wrong statement seems to hold for a vast amount of data.
Known exception: T(1, 90) = 37 but T(27, 90) = 0.
Formerly it was stated that this is a theorem:
"(T( (1 + 2*n)*m, n) - n)/T(m, n) = 1 + 2*n if T(m, n) > 0."
This appears to be true in the majority of cases, but misses some yet unknown conditions. (End)
The reason for the pattern in the row T(1, n) is that in this particular case a cycle is only possible if we eventually reach a power of 2 under iteration. If we look at the case 9x+1 ( Row 4 ) as an example, we can understand this by the binary representation of 9: 1001. If we multiply any number j by 9 it equals a sum of j and a left-shifted version of j. Example j = 5: 1001*101 = 1001 + 100100 = 101101. In the Collatz operation 9x+1, an interrupted sequence of ones starting at the least significant bit is required to get an uninterrupted sequence of zeros by addition of 1. But in the case 9x+1 starting with x = 1 it is not possible to reach any 2^t-1 (pattern of all ones) because of the large gap of zeros in the binary representation of 9 (1001). By each multiplication, we add a shifted copy of 1001... at the left to the bit pattern and thus add gaps that are only slowly filled up with ones by the addition of the constant. To prevent an escape into infinity, in the Collatz process either the factor needs to have a gap of zeros smaller than two zeros in sequence (compare 9 -> row 4 and 15 -> row 7), or the constant we are adding in this process needs to be big enough to fill this gap quickly, e.g., 9x+7.
A surprising mystery are the many equal elements and correlations between different rows. For many values of m, we may observe T(m, n) = T(m, n+k) for some n and k, even if 1+2*n and 1+2*(n+k) are relatively prime.
A343858 identifies each cycle by the smallest number it may reach. This information can be used to check if two entries with the same value in T(m, n) correspond to the same cycle.
We find with growing n more similarity between T(m, n) and A025480(m - 1), the related sequence A343858(m, n) has in the same fashion similarity to A000265(m).
A173732 is the compressed representation of the dynamics of row n = 1 (3x+1). But also A025480(3*n + 1) = A173732(n) and we see now A025480 connected to generalizations of the Collatz function. This suggests a special role for the original 3x+1 version in this set of functions.

Examples

			Twelve initial terms of rows 0-10 are listed below:
   n |m->
   0: 0, 0, 1, 1,  2,  2,  3,  3, 4,  4,  5,  5, ...
   1: 0, 0, 0, 1,  2,  2,  1,  3, 5,  4,  2,  3, ...
   2: 0, 0, 0, 0,  0,  2,  1,  3, 0,  1,  2,  3, ...
   3: 0, 0, 0, 1,  0,  2,  1,  3, 4,  4,  2,  5, ...
   4: 0, 3, 3, 10, 3, 17, 10, 24, 3, 31, 17, 23, ...
   5: 0, 2, 2, 7,  2,  4,  7, 17, 2, 21,  4, 27, ...
   6: 0, 1, 1, 4,  1,  7,  4, 10, 1, 13,  7,  4, ...
   7: 0, 0, 0, 1,  0,  2,  1,  3, 0,  4,  2,  5, ...
   8: 0, 7, 7, 22, 7, 37, 22, 52, 7, 67, 37, 82, ...
   9: 0, 6, 6, 19, 6, 32, 19, 14, 6, 58, 32, 71, ...
  10: 0, 5, 5, 16, 5, 27, 16, 38, 5, 49, 27, 35, ...
We may see this sequence as a sequence of functions:
in m=1: 0 -> f_n1_0(k) =  k/2; (3*k+1)/2.
        1 -> f_n1_1(k) =  k/2; (3*k+3)/2.
        2 -> f_n1_2(k) =  k/2; (3*k+5)/2.
in m=2: 0 -> f_n2_0(k) =  k/2; (5*k+1)/2.
        1 -> f_n2_1(k) =  k/2; (5*k+3)/2.
        2 -> f_n2_2(k) =  k/2; (5*k+5)/2.
T(1, 4) = 3 because: f_n4_3(1) = (9 + 7)/2 = 16, f_n4_3(18) = 16/2 = 8, f_n4_3(8) = 8/2 = 4, f_n4_3(4) = 4/2 = 2, f_n4_3(2) = 2/2 = 1.
This shows that f_n4_3(f_n4_3(f_n4_3(f_n4_3(f_n4_3(1))))) = 1.
T(1, 4) is not < 2 because no such loop which includes 1 exists for f_n4_0, f_n4_1 and f_n4_2.
		

Crossrefs

Programs

  • PARI
    \\ uses magic constant 10^5
    isperiodic(v, z) = for (k=1, #v, if (v[k] == z, return(1)));
    f(tmn, m, n) = if (m%2, ((2*n+1)*m+2*tmn+1)/2, m/2);
    isok(m, n, tmn) = {my(v=[m], y=m); for (i=1, oo, my(z=f(tmn, y, n)); if (z > 10^5, return (0)); if (z == m, return (1)); if (isperiodic(v, z), return(0)); v = concat(v, z); y = z; ); }
    T(m,n) = {my(tmn=0); while (!isok(m, n, tmn), tmn++); tmn; }
    matrix(15,15, n, k, T(k-1, n-1)) \\ Michel Marcus, Jun 17 2021

Formula

T(1, n) = A035327(n) for n > 2.
Showing 1-7 of 7 results.