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.

A004738 Concatenation of sequences (1,2,...,n-1,n,n-1,...,2) for n >= 2.

This page as a plain text file.
%I A004738 #51 Mar 02 2025 08:01:46
%S A004738 1,2,1,2,3,2,1,2,3,4,3,2,1,2,3,4,5,4,3,2,1,2,3,4,5,6,5,4,3,2,1,2,3,4,
%T A004738 5,6,7,6,5,4,3,2,1,2,3,4,5,6,7,8,7,6,5,4,3,2,1,2,3,4,5,6,7,8,9,8,7,6,
%U A004738 5,4,3,2,1,2,3,4,5,6,7,8,9,10,9,8,7,6,5,4,3,2,1,2,3,4,5,6,7,8,9,10,11,10,9
%N A004738 Concatenation of sequences (1,2,...,n-1,n,n-1,...,2) for n >= 2.
%C A004738 Also concatenation of sequences n,n-1,...,2,1,2,...,n-1,n.
%C A004738 Table T(n,k) n, k > 0, T(n,k) = n-k+1, if n >= k, T(n,k) = k-n+1, if n < k.  Table read by sides of squares from T(1,n) to T(n,n), then from T(n,n) to T(n,1). General case A209301. Let m be a natural number. The first column of the table T(n,1) is the sequence of the natural numbers A000027. In all columns with number k (k > 1) the segment with the length of (k-1): {m+k-2, m+k-3, ..., m} shifts the sequence A000027. For m=1 the result is A004739, for m=2 the result is A004738, for m=3 the result is A209301. - _Boris Putievskiy_, Jan 24 2013
%D A004738 F. Smarandache, "Numerical Sequences", University of Craiova, 1975; [ See Arizona State University, Special Collection, Tempe, AZ, USA ].
%H A004738 Boris Putievskiy, <a href="http://arxiv.org/abs/1212.2732">Transformations [Of] Integer Sequences And Pairing Functions</a>, arXiv preprint arXiv:1212.2732 [math.CO], 2012.
%H A004738 F. Smarandache, <a href="http://www.gallup.unm.edu/~smarandache/CP2.pdf">Collected Papers, Vol. II</a>
%H A004738 F. Smarandache, <a href="http://www.gallup.unm.edu/~smarandache/Sequences-book.pdf">Sequences of Numbers Involved in Unsolved Problems</a>.
%H A004738 Eric Weisstein's World of Mathematics, <a href="https://mathworld.wolfram.com/SmarandacheSequences.html">Smarandache Sequences</a>
%F A004738 a(n) = floor(sqrt(n) + 1/2) + 1 - abs(n - 1 - (floor(sqrt(n) + 1/2))^2). - _Benoit Cloitre_, Feb 08 2003
%F A004738 From _Boris Putievskiy_, Jan 24 2013: (Start)
%F A004738 For the general case, a(n) = m*v + (2*v-1)*(t*t-n) + t, where t = floor(sqrt(n) - 1/2) + 1 and v = floor((n-1)/t) - t + 1.
%F A004738 For m=2, a(n) = 2*v + (2*v-1)*(t*t-n) + t, where t = floor(sqrt(n) - 1/2) + 1 and v = floor((n-1)/t) - t + 1. (End)
%e A004738 From _Boris Putievskiy_, Jan 24 2013: (Start)
%e A004738 The start of the sequence as table:
%e A004738   1, 2, 3, 4, 5, 6, 7, ...
%e A004738   2, 1, 2, 3, 4, 5, 6, ...
%e A004738   3, 2, 1, 2, 3, 4, 5, ...
%e A004738   4, 3, 2, 1, 2, 3, 4, ...
%e A004738   5, 4, 3, 2, 1, 2, 3, ...
%e A004738   6, 5, 4, 3, 2, 1, 2, ...
%e A004738   7, 6, 5, 4, 3, 2, 1, ...
%e A004738   ...
%e A004738 The start of the sequence as triangle array read by rows:
%e A004738   1;
%e A004738   2, 1, 2;
%e A004738   3, 2, 1, 2, 3;
%e A004738   4, 3, 2, 1, 2, 3, 4;
%e A004738   5, 4, 3, 2, 1, 2, 3, 4, 5;
%e A004738   6, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6;
%e A004738   7, 6, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7;
%e A004738   ...
%e A004738 Row number r contains 2*r - 1 numbers: r, r-1, ..., 1, 2, ..., r. (End)
%p A004738 A004738 := proc(n)
%p A004738     local tri ;
%p A004738     tri := floor(sqrt(n)+1/2) ;
%p A004738     tri+1-abs(n-1-tri^2) ;
%p A004738 end proc:
%p A004738 seq(A004738(n),n=1..30) ; #_R. J. Mathar_, Feb 14 2019
%t A004738 row[n_] := Range[n, 1, -1] ~Join~ Range[2, n];
%t A004738 Array[row, 10] // Flatten (* _Jean-François Alcover_, Apr 19 2020 *)
%o A004738 (PARI) a(n)= floor(sqrt(n)+1/2)+1-abs(n-1-(floor(sqrt(n)+1/2)-1/2)^2)
%o A004738 (Python)
%o A004738 from math import isqrt
%o A004738 def A004738(n): return abs((t:=isqrt(n-1))*(t+1)-n+1)+1 # _Chai Wah Wu_, Mar 01 2025
%Y A004738 Cf. A004737, A004739, A187760, A079813, A209301.
%K A004738 nonn,easy
%O A004738 1,2
%A A004738 R. Muller
%E A004738 More terms from _Patrick De Geest_, Jun 15 1998