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.

A345967 Lexicographically first sequence of distinct positive integers such that the alternating partial sums p(n) = Sum_{k=1..n} -(-1)^k a(k), n >= 1, are distinct positive integers.

This page as a plain text file.
%I A345967 #28 Dec 21 2024 20:22:05
%S A345967 2,1,5,3,6,4,7,8,12,9,11,10,15,13,17,14,16,18,22,19,21,20,25,23,26,24,
%T A345967 28,27,30,29,32,31,35,33,36,34,37,38,42,39,43,40,44,41,45,47,46,48,55,
%U A345967 49,51,50,53,52,57,54,56,58,62,59,63,60,64,61,65,67,66,68,74,69,72,70,75,71,73,76,79,77,80,78
%N A345967 Lexicographically first sequence of distinct positive integers such that the alternating partial sums p(n) = Sum_{k=1..n} -(-1)^k a(k), n >= 1, are distinct positive integers.
%C A345967 The chess rook as a windshield wiper sequence: terms with an odd index [a(1), a(3), a(5), ...] move the chess rook horizontally to the right over a(n) terms; terms with an even index [a(2), a(4), a(6), ...] move the chess rook to the left over a(n) terms; this is the lexicographically earliest sequence of positive distinct terms such that all terms of the sequence will be visited exactly once by the rook.
%C A345967 It turns out that both, sequence (a(n), n >= 1) and that of partial alternating sums (p(n), n >= 1), are permutations of the positive integers. - _M. F. Hasler_, Jul 11 2021
%C A345967 The inverse permutation of this sequence starts (2, 1, 4, 6, 3, 5, 7, 8, 10, 12, 11, 9, 14, 16, 13, 17, 15, 18, 20, 22, 21, ...). - _M. F. Hasler_, Jul 19 2021
%H A345967 Eric Angelini, <a href="http://cinquantesignes.blogspot.com/2021/06/la-tour-dechecs-et-lessuie-glace.html">La tour d'échecs et l'essuie-glace</a>, Cinquante signes, 2021.
%H A345967 Eric Angelini, <a href="/A345967/a345967.pdf">La tour d'échecs et l'essuie-glace</a>, Cinquante signes, 2021. [Cached copy]
%H A345967 <a href="/index/Per#IntegerPermutation">Index entries for sequences that are permutations of the natural numbers</a>
%e A345967 As a(1) = 2 has an odd index, the rook moves 2 terms to the Right on a(3) = 5;
%e A345967 from there the rook moves according to a(2) = 1 (1 term to the L) on a(2) = 1;
%e A345967 from there the rook moves according to a(3) = 5 (5 terms to the R) on a(7) = 7;
%e A345967 from there the rook moves according to a(4) = 3 (3 terms to the L) on a(4) = 3;
%e A345967 from there the rook moves according to a(5) = 6 (6 terms to the R) on a(10) = 9; etc. The rook's successive movements can be seen as the movements of a windshield wiper.
%o A345967 (PARI) A345967_vec(Nmax, P=0)={ my(US=[0], UP=[P], used(x,U)= setsearch(U,x) || x<=U[1], insert(x,U)= U=setunion(U,[x]); while(#U>1&&U[2]==U[1]+1, U=U[^1]); U); vector(Nmax, n, my(s=(-1)^n); for(S=US[1]+1,oo, (used(S,US) || used(P-s*S,UP))&&next; if(s<0, my(f=1); for(PP=UP[1]+1,P+S-1, used(PP,UP) || used(P+S-PP,US) || PP==P || [f=0; break]); f && next); UP=insert(P-=s*S, UP); US=insert(s=S, US); break); s)} \\ _M. F. Hasler_, Jul 11 2021
%Y A345967 Cf. A285471.
%K A345967 nonn
%O A345967 1,1
%A A345967 _Eric Angelini_ and _Neil Bickford_, Jun 30 2021
%E A345967 Edited and better definition from _M. F. Hasler_, Jul 19 2021