login
The OEIS is supported by the many generous donors to the OEIS Foundation.

 

Logo
Hints
(Greetings from The On-Line Encyclopedia of Integer Sequences!)
A209278 Second inverse function (numbers of rows) for pairing function A185180. 4

%I #28 Feb 15 2022 12:54:40

%S 1,2,1,2,3,1,3,2,4,1,3,4,2,5,1,4,3,5,2,6,1,4,5,3,6,2,7,1,5,4,6,3,7,2,

%T 8,1,5,6,4,7,3,8,2,9,1,6,5,7,4,8,3,9,2,10,1,6,7,5,8,4,9,3,10,2,11,1

%N Second inverse function (numbers of rows) for pairing function A185180.

%H Boris Putievskiy, <a href="/A209278/b209278.txt">Rows n = 1..140 of triangle, flattened</a>

%H Boris Putievskiy, <a href="http://arxiv.org/abs/1212.2732">Transformations Integer Sequences And Pairing Functions</a>, arXiv:1212.2732 [math.CO], 2012.

%H Eric Weisstein's World of Mathematics, <a href="http://mathworld.wolfram.com/PairingFunction.html">Pairing functions</a>

%F a(n) = floor((A003056(n)+3)/2) + floor(A002260(n)/2)*(-1)^(A002260(n)+A003056(n)).

%F a(n)= floor((t+3)/2)+ floor(i/2)*(-1)^(i+t),

%F where t=floor((-1+sqrt(8*n-7))/2), i=n-t*(t+1)/2.

%F T(r,2s-1)=s, T(r,2s)= r+s. (When read as square array by antidiagonals.)

%e The start of the sequence as table T(r,s) r,s >0 read by antidiagonals:

%e 1...2...2...3...3...4...4...5...

%e 1...3...2...4...3...5...4...6...

%e 1...4...2...5...3...6...4...7...

%e 1...5...2...6...3...7...4...8...

%e 1...6...2...7...3...8...4...9...

%e 1...7...2...8...3...9...4..10...

%e 1...8...2...9...3..10...4..11...

%e . . .

%e The start of the sequence as triangle array read by rows:

%e 1;

%e 2, 1;

%e 2, 3, 1;

%e 3, 2, 4, 1;

%e 3, 4, 2, 5, 1;

%e 4, 3, 5, 2, 6, 1;

%e 4, 5, 3, 6, 2, 7, 1;

%e 5, 4, 6, 3, 7, 2, 8, 1;

%e . . .

%e Row number r contains permutation numbers form 1 to r.

%e If r is odd (r+1)/2, (r+1)/2 +1, (r+1)/2 -1, ... 2, r, 1.

%e If r is even r/2 + 1, r/2, r/2 + 2, ... 2, r, 1.

%t T[r_, s_] := If[OddQ[s], (s+1)/2, r + s/2];

%t Table[T[r-s+1, s], {r, 1, 11}, {s, r, 1, -1}] // Flatten (* _Jean-François Alcover_, Nov 19 2019 *)

%o (Python)

%o t=int((math.sqrt(8*n-7) - 1)/ 2)

%o i=n-t*(t+1)/2

%o result=int((t+3)/2)+int(i/2)*(-1)**(i+t)

%o (PARI) T(r,s)=s\2+if(bittest(s,0),1,r) \\ - _M. F. Hasler_, Jan 15 2013

%Y Cf. A185180, A092542, A092543.

%K nonn,tabl

%O 1,2

%A _Boris Putievskiy_, Jan 15 2013

Lookup | Welcome | Wiki | Register | Music | Plot 2 | Demos | Index | Browse | More | WebCam
Contribute new seq. or comment | Format | Style Sheet | Transforms | Superseeker | Recents
The OEIS Community | Maintained by The OEIS Foundation Inc.

License Agreements, Terms of Use, Privacy Policy. .

Last modified April 25 03:15 EDT 2024. Contains 371964 sequences. (Running on oeis4.)