login
Pyramidal sequence: distance to nearest product of two consecutive integers (promic or heteromecic numbers).
11

%I #51 Aug 29 2020 14:01:24

%S 0,1,0,1,2,1,0,1,2,3,2,1,0,1,2,3,4,3,2,1,0,1,2,3,4,5,4,3,2,1,0,1,2,3,

%T 4,5,6,5,4,3,2,1,0,1,2,3,4,5,6,7,6,5,4,3,2,1,0,1,2,3,4,5,6,7,8,7,6,5,

%U 4,3,2,1,0,1,2,3,4,5,6,7,8,9,8,7,6,5,4,3,2,1,0,1,2,3,4,5,6,7,8,9,10,9,8,7

%N Pyramidal sequence: distance to nearest product of two consecutive integers (promic or heteromecic numbers).

%C a(A002378(n)) = 0; a(n^2) = n.

%C Table A049581 T(n,k) = |n-k| read by sides of squares from T(1,n) to T(n,n), then from T(n,n) to T(n,1). - _Boris Putievskiy_, Jan 29 2013

%H Harvey P. Dale, <a href="/A053615/b053615.txt">Table of n, a(n) for n = 0..1000</a>

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

%H <a href="/index/Di#distance_to_the_nearest">Index entries for sequences related to distance to nearest element of some set</a>

%F a(n) = A004738(n+1) - 1.

%F Let u(1)=1, u(n) = n - u(n-sqrtint(n)) (cf. A037458); then a(0)=0 and for n > 0 a(n) = 2*u(n) - n. - _Benoit Cloitre_, Dec 22 2002

%F a(0)=0 then a(n) = floor(sqrt(n)) - a(n - floor(sqrt(n))). - _Benoit Cloitre_, May 03 2004

%F a(n) = |A196199(n)|. a(n) = |n - t^2 - t|, where t = floor(sqrt(n)). - _Boris Putievskiy_, Jan 29 2013 [corrected by _Ridouane Oudra_, May 11 2019]

%F a(n) = A000194(n) - A053188(n) = t - |t^2 - n|, where t = floor(sqrt(n)+1/2). - _Ridouane Oudra_, May 11 2019

%e a(10) = |10 - 3*4| = 2.

%e From _Boris Putievskiy_, Jan 29 2013: (Start)

%e The start of the sequence as table:

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

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

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

%e 3, 2, 1, 0, 1, 2, 3, 4, ...

%e 4, 3, 2, 1, 0, 1, 2, 3, ...

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

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

%e ...

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

%e 0;

%e 1, 0, 1;

%e 2, 1, 0, 1, 2;

%e 3, 2, 1, 0, 1, 2, 3;

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

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

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

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

%e ...

%e Row number r contains 2*r-1 numbers: r-1, r-2, ..., 0, 1, 2, ..., r-1. (End)

%p A053615 := proc(n)

%p A004738(n+1)-1 ; # reuses code of A004738

%p end proc:

%p seq(A053615(n),n=0..30) ; # _R. J. Mathar_, Feb 14 2019

%t a[0] = 0; a[n_] := Floor[Sqrt[n]] - a[n - Floor[Sqrt[n]]]; Table[a[n], {n, 0, 103}] (* _Jean-François Alcover_, Dec 16 2011, after _Benoit Cloitre_ *)

%t Join[{0},Module[{nn=150,ptci},ptci=Times@@@Partition[Range[nn/2+1],2,1];Table[Abs[n-Nearest[ptci,n]],{n,nn}][[All,1]]]] (* _Harvey P. Dale_, Aug 29 2020 *)

%o (PARI) a(n)=if(n<1,0,sqrtint(n)-a(n-sqrtint(n)))

%Y Cf. A002262, A002378, A004738, A049581, A053188, A196199.

%K easy,nice,nonn

%O 0,5

%A _Henry Bottomley_, Mar 20 2000