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.

Previous Showing 11-20 of 25 results. Next

A167808 Numerator of x(n), where x(n) = x(n-1) + x(n-2) with x(0)=0, x(1)=1/2.

Original entry on oeis.org

0, 1, 1, 1, 3, 5, 4, 13, 21, 17, 55, 89, 72, 233, 377, 305, 987, 1597, 1292, 4181, 6765, 5473, 17711, 28657, 23184, 75025, 121393, 98209, 317811, 514229, 416020, 1346269, 2178309, 1762289, 5702887, 9227465, 7465176, 24157817, 39088169, 31622993
Offset: 0

Views

Author

Reinhard Zumkeller, Nov 12 2009

Keywords

Comments

Define a sequence c(n) by c(0)=0, c(1)=1; thereafter c(n) = (c(n-2)*c(n-1)-1)/(c(n-2)+c(n-1)+2). Then it appears that (apart from signs), a(n) is the denominator of c(n). - Jonas Holmvall, Jun 21 2023

Crossrefs

Cf. A000045, A130196 (denominator).
The a(2*n) appear in A179135. - Johannes W. Meijer, Jul 01 2010

Programs

  • GAP
    a:=[0,1,1,1,3,5];; for n in [7..40] do a[n]:=4*a[n-3]+a[n-6]; od; a; # Muniru A Asiru, Oct 16 2018
  • Maple
    nmax:=39; x(0):=0: x(1):=1/2:for n from 2 to nmax do x(n):=x(n-1)+x(n-2) od: for n from 0 to nmax do a(n):= numer(x(n)) od: seq(a(n),n=0..nmax); # Johannes W. Meijer, Jul 01 2010
    with(combinat):f:=n->fibonacci(n):L:=n->f(n)+2*f(n-1):seq(numer(f(n)/L(n)), n=0..39); # Gary Detlefs, Dec 11 2010
  • Mathematica
    f[n_]:=Numerator[Fibonacci[n]/Fibonacci[n+3]];Array[f,100,0] (* Vladimir Joseph Stephan Orlovsky, Feb 17 2011*)
    Numerator[LinearRecurrence[{1,1},{0,1/2},40]] (* Harvey P. Dale, Aug 08 2014 *)
    CoefficientList[Series[-x (1 + x + x^2 - x^3 + x^4)/((x^2 + x - 1) (x^4 - x^3 + 2 x^2 + x + 1)), {x, 0, 40}], x] (* Vincenzo Librandi, Aug 08 2014 *)
    LinearRecurrence[{0, 0, 4, 0, 0, 1},{0, 1, 1, 1, 3, 5},40] (* Ray Chandler, Aug 03 2015 *)
    a[n_]:=If[Mod[n,3]==0, Fibonacci[n]/2, Fibonacci[n]]; Array[a, 40, 0] (* Stefano Spezia, Oct 16 2018 *)

Formula

a(n) = (a(n-1)*A131534(n) + a(n-2)*A131534(n+2))/A131534(n+1) for n > 1.
a(3*n) = A001076(n) = (a(3*n-1) + a(3*n-2))/2;
a(3*n+1) = A033887(n) = 2*a(3*n-1) + a(3*n-2);
a(3*n+2) = A015448(n+1) = a(3*n-1) + 2*a(3*n-2).
From Johannes W. Meijer, Jul 01 2010: (Start)
a(2*n) = A001906(n)/A131534(n+1) for n >= 0 and a(2*n+1) = A179131(n)/5 for n >= 1.
a(6*n+2) - 2*a(6*n) = A134493(n);
2*a(6*n+1) - a(6*n+3) = A023039(n);
2*a(6*n+4) - a(6*n+2) = A134497(n);
a(6*n+5) - 2*a(6*n+3) = A103134(n);
2*a(6*n+4) - a(6*n+6) = A075796(n).
(End)
From Gary Detlefs, Dec 11 2010: (Start)
a(n) = numerator(A000045(n)/A000032(n)).
If n mod 3 = 0 then a(n) = Fibonacci(n)/2, else a(n)= Fibonacci(n). (End)
G.f.: -x*(1 + x + x^2 - x^3 + x^4) / ( (x^2 + x - 1)*(x^4 - x^3 + 2*x^2 + x + 1) ). - R. J. Mathar, Mar 08 2011
a(n) = 4*a(n-3) + a(n-6). - Muniru A Asiru, Oct 16 2018

Extensions

Typo in title corrected by Johannes W. Meijer, Jun 26 2010

A134751 Hankel transform of expansion of (1/(1-x^2))c(x/(1-x^2)), where c(x) is the g.f. of A000108.

Original entry on oeis.org

1, 2, 8, 32, 256, 4096, 65536, 2097152, 134217728, 8589934592, 1099511627776, 281474976710656, 72057594037927936, 36893488147419103232, 37778931862957161709568, 38685626227668133590597632
Offset: 0

Views

Author

Paul Barry, Nov 08 2007

Keywords

Comments

Hankel transform of A105864.
The sequence 1,1,2,8,... with general term 2^floor(n^2/3) is the Hankel transform of A109033. - Paul Barry, Dec 14 2008

Programs

  • Mathematica
    a[ n_] := 2^Quotient[(n+1)^2, 3]; (* Michael Somos, May 12 2022 *)
  • PARI
    {a(n) = 2^((n+1)^2\3)}; /* Michael Somos, May 12 2022 */

Formula

a(n) = 2^floor((n+1)^2/3);
a(n) = Product_{k=1..n} (5/3 - 2*cos(2*Pi*k/3)/3)^(n-k+1);
a(n) = Product_{k=1..n} A130196(k)^(n-k+1).
a(n) = 4*a(n-1)*a(n-3)/a(n-4). Somos-4 sequence associated to, e.g., y^2 = 1 - 8x + 16x^2 - 8x^3. - Paul Barry, Nov 27 2009
a(n) = a(-2-n) for all n in Z. - Michael Somos, May 12 2022

A105396 A simple "Fractal Jump Sequence" (FJS).

Original entry on oeis.org

3, 6, 6, 3, 6, 6, 3, 6, 6, 3, 6, 6, 3, 6, 6, 3, 6, 6, 3, 6, 6, 3, 6, 6, 3, 6, 6, 3, 6, 6, 3, 6, 6, 3, 6, 6, 3, 6, 6, 3, 6, 6, 3, 6, 6, 3, 6, 6, 3, 6, 6, 3, 6, 6, 3, 6, 6, 3, 6, 6, 3, 6, 6, 3, 6, 6, 3, 6, 6, 3, 6, 6, 3, 6, 6, 3, 6, 6, 3, 6, 6, 3, 6, 6, 3, 6, 6, 3, 6, 6, 3, 6, 6, 3, 6, 6, 3, 6, 6, 3, 6, 6, 3, 6, 6
Offset: 3

Views

Author

Eric Angelini, May 01 2005

Keywords

Comments

See A105397 for definition of Fractal Jump Sequence.
From Vincenzo Librandi, Nov 13 2010: (Start)
First digit after the decimal point in the decimal expansion of (n^2 - 2)/3 (with n > 2). Examples:
for n=3, (3^2-2)/3 = 2.(3);
for n=4, (4^2-2)/3 = 4.(6);
for n=5, (5^2-2)/3 = 7.(6);
for n=6, (6^2-2)/3 = 11.(3);
for n=7, (7^2-2)/3 = 15.(6). (End)

Crossrefs

Equals 3*A130196.

Formula

From Robert Israel, Aug 04 2019: (Start)
a(n)=3 if 3|n, otherwise a(n)=6.
G.f.: 3*(1+2*x+2*x^2)*x^3/(1-x^3). (End)

A167817 Period 4: repeat [1, 3, 3, 3].

Original entry on oeis.org

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

Views

Author

Reinhard Zumkeller, Nov 13 2009

Keywords

Comments

Denominator of x(n) = x(n-1) + x(n-2), x(0)=0, x(1)=1/3; numerator = A167816(n).
Continued fraction expansion of (33 + sqrt(2805))/66. - Klaus Brockhaus, May 06 2010

Crossrefs

Cf. A130196.
Cf. A177344 (decimal expansion of (33+sqrt(2805))/66). - Klaus Brockhaus, May 06 2010

Programs

  • Magma
    &cat[[1, 3, 3, 3]: n in [0..50]]; // Vincenzo Librandi, Dec 28 2010
  • Maple
    seq(op([1, 3, 3, 3]), n=0..50); # Wesley Ivan Hurt, Jul 09 2016
  • Mathematica
    Denominator[LinearRecurrence[{1,1},{0,1/3},110]] (* or *) PadRight[{},110,{1,3,3,3}] (* Harvey P. Dale, Dec 07 2014 *)
    LinearRecurrence[{0, 0, 0, 1},{1, 3, 3, 3},105] (* Ray Chandler, Aug 03 2015 *)

Formula

a(n) = 3 - 2 * 0^(n mod 4).
G.f.: (1 + 3*x + 3*x^2 + 3*x^3)/(1-x^4). - Klaus Brockhaus, May 06 2010
a(n) = 5/2 - cos(Pi*n/2) - (-1)^n/2. - R. J. Mathar, Oct 08 2011
E.g.f.: -cos(x) + 3*sinh(x) + 2*cosh(x). - Ilya Gutkovskiy, Jun 27 2016
a(n) = a(n-4) for n>3. - Wesley Ivan Hurt, Jul 09 2016

Extensions

Definition corrected by D. S. McNeil, May 09 2010

A179135 a(n) = (3-sqrt(5))*((3+sqrt(5))/10)^(-n)/2+(3+sqrt(5))*((3-sqrt(5))/10)^(-n)/2.

Original entry on oeis.org

3, 35, 450, 5875, 76875, 1006250, 13171875, 172421875, 2257031250, 29544921875, 386748046875, 5062597656250, 66270263671875, 867489013671875, 11355578613281250, 148646453857421875, 1945807342529296875
Offset: 0

Views

Author

Johannes W. Meijer, Jul 01 2010

Keywords

Crossrefs

Cf. A109106.

Programs

  • Maple
    with(GraphTheory): nmax:=72; P:=9: G:=PathGraph(P): A:= AdjacencyMatrix(G): for n from 0 to nmax do B(n):=A^n; A178381(n):=add(B(n)[1,k],k=1..P); od: for n from 0 to nmax/4-1 do a(n):= A178381(4*n+3) od: seq(a(n),n=0..nmax/4-1);

Formula

a(n) = A178381(4*n+3).
G.f.: (3-10*z)/(1-15*z+25*z^2).
Limit(a(n+k)/a(k), k=infinity) = A000351(n)*A130196(n)/(A128052(n) - A167808(2*n)*sqrt(5)).
Limit(A128052(n)/A167808(2*n),n=infinity) = sqrt(5).
a(n) = 5^n*Lucas(2*(n+1)). - Ehren Metcalfe, Apr 22 2018

A213927 T(n,k) = (z*(z-1)-(-1+(-1)^(z^2 mod 3))*n+(1+(-1)^(z^2 mod 3))*k)/2, where z=n+k-1; n, k > 0, read by antidiagonals.

Original entry on oeis.org

1, 2, 3, 6, 5, 4, 7, 8, 9, 10, 11, 12, 13, 14, 15, 21, 20, 19, 18, 17, 16, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 45, 44, 43, 42, 41, 40, 39, 38, 37, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 78
Offset: 1

Views

Author

Boris Putievskiy, Mar 06 2013

Keywords

Comments

Self-inverse permutation of the natural numbers.
a(n) is a pairing function: a function that reversibly maps Z^{+} x Z^{+} onto Z^{+}, where Z^{+} is the set of integer positive numbers.
In general, let b(z) be a sequence of integers and denote number of antidiagonal table T(n,k) by z=n+k-1. Natural numbers placed in table T(n,k) by antidiagonals. The order of placement - by antidiagonal downwards, if b(z) is odd; by antidiagonal upwards, if b(z) is even. T(n,k) read by antidiagonals downwards. For A218890 -- the order of placement -- at the beginning m antidiagonals downwards, next m antidiagonals upwards and so on - b(z)=floor((z+m-1)/m). For this sequence b(z)=z^2 mod 3. (This comment should be edited for clarity, Joerg Arndt, Dec 11 2014)

Examples

			The start of the sequence as table.
The direction of the placement denoted by ">" and  "v".
.v.....v       v...v        v....v
.1.....2...6...7..11...21...22...29...45...
.3.....5...8..12..20...23...30...44...47...
>4.....9..13..19..24...31...43...48...58...
.10...14..18..25..32...42...49...59...75...
.15...17..26..33..41...50...60...74...83...
>16...27..34..40..51...61...73...84...97...
.28...35..39..52..62...72...85...98..114...
.36...38..53..63..71...86...99..113..128...
>37...54..64..70..87..100..112..129..145...
...
The start of the sequence as triangle array read by rows:
   1;
   2,  3;
   6,  5,  4;
   7,  8,  9, 10;
  11, 12, 13, 14, 15;
  21, 20, 19, 18, 17, 16;
  22, 23, 24, 25, 26, 27, 28;
  29, 30, 31, 32, 33, 34, 35, 36;
  45, 44, 43, 42, 41, 40, 39, 38, 37;
  ...
Row r consists of r consecutive numbers from r*r/2-r/2+1 to r*r/2+r.
If r is not divisible by 3, rows are increasing.
If r is     divisible by 3, rows are decreasing.
		

Crossrefs

Programs

  • Mathematica
    T[n_, k_] := With[{z = n + k - 1}, (z*(z - 1) - (-1 + (-1)^Mod[z^2, 3])*n + (1 + (-1)^Mod[z^2, 3])*k)/2];
    Table[T[n - k + 1, k], {n, 1, 12}, {k, n, 1, -1}] // Flatten (* Jean-François Alcover, Jul 22 2018 *)
  • Python
    t=int((math.sqrt(8*n-7) - 1)/ 2)
    i=n-t*(t+1)/2
    j=(t*t+3*t+4)/2-n
    z=i+j-1
    result=(z*(z-1)-(-1+(-1)**(z**2%3))*i+(1+(-1)**(z**2%3))*j)/2

Formula

For the general case.
T(n,k) = (z*(z-1)-(-1+(-1)^b(z))*n+(1+(-1)^b(z))*k)/2, where z=n+k-1 (as a table).
a(n) = (z*(z-1)-(-1+(-1)^b(z))*i+(1+(-1)^b(z))*j)/2, where i=n-t*(t+1)/2, j=(t*t+3*t+4)/2-n, t=floor((-1+sqrt(8*n-7))/2), z=i+j-1 (as a linear sequence).
For this sequence b(z)=z^2 mod 3.
T(n,k) = (z*(z-1)-(-1+(-1)^(z^2 mod 3))*n+(1+(-1)^(z^2 mod 3))*k)/2, where z=n+k-1 (as a table).
a(n) = (z*(z-1)-(-1+(-1)^(z^2 mod 3))*i+(1+(-1)^(z^2 mod 3))*j)/2, where i=n-t*(t+1)/2, j=(t*t+3*t+4)/2-n, t=floor((-1+sqrt(8*n-7))/2), z=i+j-1 (as linear sequence).

A121963 Expansion of x^2*(1 + 2*x + 7*x^2 - 3*x^3 + x^4)/(1 - 26*x^3 - x^6).

Original entry on oeis.org

0, 1, 2, 7, 23, 53, 182, 599, 1380, 4739, 15597, 35933, 123396, 406121, 935638, 3213035, 10574743, 24362521, 83662306, 275349439, 634361184, 2178432991, 7169660157, 16517753305, 56722920072, 186686513521, 430095947114
Offset: 1

Views

Author

Roger L. Bagula, Sep 02 2006

Keywords

Comments

a(n) is a component of the n-th partial product of 2 X 2 matrices with rows (0,1), (1, 1 + A130196(j)), j>=1.
The linear recurrence shows that these are three interleaved sequences (0,7,182,...), (1,23,599,...) and (2,53,1380,...) obeying simple recurrences of the form b(n) = 26*b(n-1) + b(n-2).

Programs

  • GAP
    a:=[1,2,9];; for n in [7..30] do a[n]:=26*a[n-3]+a[n-6]; od; a; # G. C. Greubel, Oct 05 2019
  • Magma
    I:=[0,1,2,7,23,53]; [n le 6 select I[n] else 26*Self(n-3) +Self(n-6): n in [1..30]]; // G. C. Greubel, Oct 05 2019
    
  • Maple
    seq(coeff(series(x^2*(1+2*x+7*x^2-3*x^3+x^4)/(1-26*x^3-x^6), x, n+1), x, n), n = 1..30); # G. C. Greubel, Oct 05 2019
  • Mathematica
    M[n_] := {{0,1}, {1, 1+Mod[n^2-n-1, 3]} }; v[1] = {0,1}; v[n_] := v[n] = M[n].v[n-1]; Table[v[n][[1]], {n,30}]
    Rest@CoefficientList[Series[x^2*(1+2*x+7*x^2-3*x^3+x^4)/(1-26*x^3-x^6), {x,0,30}], x] (* G. C. Greubel, Oct 05 2019 *)
  • PARI
    my(x='x+O('x^30)); concat([0], Vec(x^2*(1+2*x+7*x^2-3*x^3 +x^4)/( 1-26*x^3-x^6))) \\ G. C. Greubel, Oct 05 2019
    
  • Sage
    def A121963_list(prec):
        P. = PowerSeriesRing(ZZ, prec)
        return P( x^2*(1+2*x+7*x^2-3*x^3+x^4)/(1-26*x^3-x^6) ).list()
    a=A121963_list(30); a[1:] # G. C. Greubel, Oct 05 2019
    

A129765 Triangle, (1, 1, 2, 2, 2, ...) in every column.

Original entry on oeis.org

1, 1, 1, 2, 1, 1, 2, 2, 1, 1, 2, 2, 2, 1, 1, 2, 2, 2, 2, 1, 1, 2, 2, 2, 2, 2, 1, 1, 2, 2, 2, 2, 2, 2, 1, 1, 2, 2, 2, 2, 2, 2, 2, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 1
Offset: 1

Views

Author

Gary W. Adamson, May 16 2007

Keywords

Comments

Row sums = A004277, (1, 2, 4, 6, 8, 10, ...). Binomial transform of (1, 1, 2, 2, 2, ...) = A000325, starting (1, 2, 5, 12, 27, 58, ...). Binomial transform of A130196 = A130197, a triangle with row sums = the Cullen numbers, A002064.

Examples

			First few rows of the triangle:
  1;
  1, 1;
  2, 1, 1;
  2, 2, 1, 1;
  2, 2, 2, 1, 1;
  ...
		

Crossrefs

Programs

  • Maple
    A129765 := proc(n,m) if abs(n-m)<2 then 1 ; else 2 ; end if ; end proc:
    for n from 1 to 18 do for m from 1 to n do printf("%d,", A129765(n,m)) ; od ; od ; # R. J. Mathar, Jun 08 2007
  • Mathematica
    Table[PadLeft[{1,1},n,2],{n,20}]//Flatten (* Harvey P. Dale, May 20 2019 *)

Formula

Triangle, (1, 1, 2, 2, 2, ...) in every column. By rows, (1; 1, 1; 2, 1, 1; ...), continuing with (n-2) 2's followed by two 1's. Inverse of A000012 as an infinite lower triangular matrix (all 1's and the rest zeros), signed by columns: (+ - - + + - -, ...).

Extensions

More terms from R. J. Mathar, Jun 08 2007

A131714 Period 6: repeat [1, -2, 2, -1, 2, -2].

Original entry on oeis.org

1, -2, 2, -1, 2, -2, 1, -2, 2, -1, 2, -2, 1, -2, 2, -1, 2, -2, 1, -2, 2, -1, 2, -2, 1, -2, 2, -1, 2, -2, 1, -2, 2, -1, 2, -2, 1, -2, 2, -1, 2, -2, 1, -2, 2, -1, 2, -2, 1, -2, 2, -1, 2, -2, 1, -2, 2, -1, 2, -2, 1, -2, 2, -1, 2, -2, 1, -2, 2, -1, 2, -2, 1, -2
Offset: 0

Views

Author

Paul Curtz, Sep 14 2007

Keywords

Crossrefs

Programs

Formula

G.f.: (1-2*x+2*x^2)/(x+1)/(x^2-x+1). - R. J. Mathar, Nov 14 2007
From Wesley Ivan Hurt, Jun 19 2016: (Start)
a(n) + a(n-3) = 0 for n>2.
a(n) = (5*cos(n*Pi)-2*cos(n*Pi/3))/3. (End)

A213928 Natural numbers placed in table T(n,k) layer by layer. The order of placement - at the beginning 2 layers counterclockwise, next 1 layer clockwise and so on. T(n,k) read by antidiagonals.

Original entry on oeis.org

1, 4, 2, 5, 3, 9, 16, 6, 8, 10, 25, 15, 7, 11, 17, 26, 24, 14, 12, 18, 36, 49, 27, 23, 13, 19, 35, 37, 64, 48, 28, 22, 20, 34, 38, 50, 65, 63, 47, 29, 21, 33, 39, 51, 81, 100, 66, 62, 46, 30, 32, 40, 52, 80, 82, 121, 99, 67, 61, 45, 31, 41, 53, 79, 83, 101
Offset: 1

Views

Author

Boris Putievskiy, Mar 06 2013

Keywords

Comments

Permutation of the natural numbers. a(n) is a pairing function: a function that reversibly maps Z^{+} x Z^{+} onto Z^{+}, where Z^{+} is the set of integer positive numbers.In general, let b(z) be a sequence of integer numbers. Layer is pair of sides of square from T(1,n) to T(n,n) and from T(n,n) to T(n,1). Natural numbers placed in table T(n,k) layer by layer. The order of placement - layer is counterclockwise, if b(z) is odd; layer is clockwise if b(z) is even. T(n,k) read by antidiagonals.For A219159 - the order of the placement - at the beginning m layers counterclockwise, next m layers clockwise and so on - b(z)=floor((z-1)/m)+1. For this sequence b(z)=z^2 mod 3.

Examples

			The start of the sequence as table.
The direction of the placement denotes by ">" and  "v".
  ..........v...........v...........v
  >1....4...5..16..25..26..49..64..65...
  >2....3...6..15..24..27..48..63..66...
  .9....8...7..14..23..28..47..62..67...
  >10..11..12..13..22..29..46..61..68...
  >17..18..19..20..21..30..45..60..69...
  .36..35..34..33..32..31..44..59..70...
  >37..38..39..40..41..42..43..58..71...
  >50..51..52..53..54..55..56..57..72...
  .81..80..79..78..77..76..75..74..73...
  . . .
The start of the sequence as triangle array read by rows:
  1;
  4,2;
  5,3,9;
  16,6,8,10;
  25,15,7,11,17;
  26,24,14,12,18,36;
  49,27,23,13,19,35,37;
  64,48,28,22,20,34,38,50;
  65,63,47,29,21,33,39,51,81;
  . . .
		

Crossrefs

Programs

  • Python
    t=int((math.sqrt(8*n-7) - 1)/ 2)
    i=n-t*(t+1)/2
    j=(t*t+3*t+4)/2-n
    if j>=i:
       result=((1+(-1)**(j**2%3-1))*(j**2-i+1)-(-1+(-1)**(j**2%3-1))*((j-1)**2 +i))/2
    else:
       result=((1+(-1)**(i**2%3))*(i**2-j+1)-(-1+(-1)**(i**2%3))*((i-1)**2 +j))/2

Formula

For general case.
As table
T(n,k) = ((1+(-1)^(b(k)-1))*(k^2-n+1)-(-1+(-1)^(b(k)-1))*((k-1)^2 +n))/2, if k >= n;
T(n,k) = ((1+(-1)^b(n))*(n^2-k+1)-(-1+(-1)^b(n))*((n-1)^2 +k))/2, if n >k.
As linear sequence
a(n) = ((1+(-1)^(b(j)-1))*(j^2-i+1)-(-1+(-1)^(b(j)-1))*((j-1)^2 +i))/2, if j >= i;
a(n) = ((1+(-1)^b(i))*(i^2-j+1)-(-1+(-1)^b(i))*((i-1)^2 +j))/2, if i >j;
where i=n-t*(t+1)/2, j=(t*t+3*t+4)/2-n, t=floor((-1+sqrt(8*n-7))/2).
For this sequence b(z)=z^2 mod 3.
As table
T(n,k) = ((1+(-1)^(k^2 mod 3-1))*(k^2-n+1)-(-1+(-1)^(k^2 mod 3-1))*((k-1)^2 +n))/2, if k >= n;
T(n,k) = ((1+(-1)^(n^2 mod 3))*(n^2-k+1)-(-1+(-1)^(n^2 mod 3))*((n-1)^2 +k))/2, if n >k.
As linear sequence
a(n) = ((1+(-1)^(j^2 mod 3-1))*(j^2-i+1)-(-1+(-1)^(j^2 mod 3-1))*((j-1)^2 +i))/2, if j >= i;
a(n) = ((1+(-1)^(i^2 mod 3))*(i^2-j+1)-(-1+(-1)^(i^2 mod 3))*((i-1)^2 +j))/2, if i >j;
where i=n-t*(t+1)/2, j=(t*t+3*t+4)/2-n, t=floor((-1+sqrt(8*n-7))/2).
Previous Showing 11-20 of 25 results. Next