login
Numbers that are exactly halfway between the nearest square and the nearest power of 2.
1

%I #20 Dec 27 2023 15:48:17

%S 3,6,34,136,498,2082,8146,32946,131058,524232,2096928,8387712,

%T 33550848,134226562,536859906,2147439624,8589943858,34359775432,

%U 137439101728,549756406912,2199022661826,8796090647304,35184374452498,140737497809992,562949943786834,2251799775147336

%N Numbers that are exactly halfway between the nearest square and the nearest power of 2.

%C Numbers that are the arithmetic mean of the nearest square and the nearest power of 2 (other than that nearest square).

%H Chai Wah Wu, <a href="/A249875/b249875.txt">Table of n, a(n) for n = 1..501</a>

%e 3 is a term because 2<3<4; 6 is a term because 4<6<8.

%o (Python)

%o def isqrt(a):

%o sr = 1 << (a.bit_length() >> 1)

%o while a < sr * sr:

%o sr >>= 1

%o b = sr >> 1

%o while b:

%o s = sr + b

%o if a >= s * s:

%o sr = s

%o b >>= 1

%o return sr

%o for j in range(99):

%o i = 2**j

%o r = isqrt(i)

%o if r * r == i:

%o continue

%o if r & 1:

%o a = ((r + 1) * (r + 1) + i) // 2

%o else:

%o a = (i + r * r) // 2

%o print(a, end=', ')

%o (Python)

%o from gmpy2 import isqrt

%o A249875_list, x = [], 1

%o for _ in range(10**3):

%o A249875_list.append(2*sum(divmod(isqrt(2*x),2))**2+x)

%o x *= 4 # _Chai Wah Wu_, Dec 16 2014

%Y Cf. A000290, A000079, A233074, A233075.

%K nonn

%O 1,1

%A _Alex Ratushnyak_, Nov 07 2014