login
The largest number not exceeding n^2, such that there are no terms of the sequence in the interval (a(n-1)/2, a(n)/2), with a(0)=0, a(1)=1.
3

%I #33 May 21 2022 08:28:47

%S 0,1,2,4,8,16,32,49,64,81,98,121,128,162,196,225,242,256,324,361,392,

%T 441,450,484,512,625,648,722,784,841,882,900,968,1024,1156,1225,1250,

%U 1296,1444,1521,1568,1681,1682,1764,1800,1936,2048,2209,2304,2312,2450

%N The largest number not exceeding n^2, such that there are no terms of the sequence in the interval (a(n-1)/2, a(n)/2), with a(0)=0, a(1)=1.

%C Every term has the form s*2^k, where s>=0 is a square and k>=0.

%H Alois P. Heinz, <a href="/A217833/b217833.txt">Table of n, a(n) for n = 0..1000</a>

%F a(n) = min(2*a(k+1), n^2) for n>=2 and a(k) <= a(n-1)/2 < a(k+1).

%e Let us find a(6), knowing the previous terms. Since a(5) = 16 and a(4)<=16/2<a(5). Then a(6) = 2*a(5) = 32, since 32<6^2 = 36. Further, since a(5)<=a(6)/2<a(6), then a(7) = 7^2 = 49, since 49<2*a(6) = 64.

%p a:= proc(n) option remember; local i, j, k, t;

%p if n<2 then n

%p else i, j, k, t:= 0, n-1, iquo(n-1, 2), a(n-1)/2;

%p while k<>i do if a(k)<=t then i:=k else j:=k fi;

%p k:= iquo(i+j,2) od;

%p min(n^2, 2*a(k+1))

%p fi

%p end:

%p seq (a(n), n=0..100); # _Alois P. Heinz_, Nov 03 2012

%t a[n_] := a[n] = Module[{i, j, k, t}, If[n < 2, n,

%t {i, j, k, t} = {0, n-1, Quotient[n-1, 2], a[n-1]/2};

%t While[k != i, If[a[k] <= t, i = k, j = k]; k = Quotient[i+j, 2]];

%t Min[n^2, 2*a[k+1]]]];

%t Table[a[n], {n, 0, 100}] (* _Jean-François Alcover_, May 20 2022, after _Alois P. Heinz_ *)

%Y Cf. A217689.

%K nonn

%O 0,3

%A _Vladimir Shevelev_, Oct 12 2012

%E More terms from _Alois P. Heinz_, Nov 02 2012