login
A249875
Numbers that are exactly halfway between the nearest square and the nearest power of 2.
1
3, 6, 34, 136, 498, 2082, 8146, 32946, 131058, 524232, 2096928, 8387712, 33550848, 134226562, 536859906, 2147439624, 8589943858, 34359775432, 137439101728, 549756406912, 2199022661826, 8796090647304, 35184374452498, 140737497809992, 562949943786834, 2251799775147336
OFFSET
1,1
COMMENTS
Numbers that are the arithmetic mean of the nearest square and the nearest power of 2 (other than that nearest square).
LINKS
EXAMPLE
3 is a term because 2<3<4; 6 is a term because 4<6<8.
PROG
(Python)
def isqrt(a):
sr = 1 << (a.bit_length() >> 1)
while a < sr * sr:
sr >>= 1
b = sr >> 1
while b:
s = sr + b
if a >= s * s:
sr = s
b >>= 1
return sr
for j in range(99):
i = 2**j
r = isqrt(i)
if r * r == i:
continue
if r & 1:
a = ((r + 1) * (r + 1) + i) // 2
else:
a = (i + r * r) // 2
print(a, end=', ')
(Python)
from gmpy2 import isqrt
A249875_list, x = [], 1
for _ in range(10**3):
A249875_list.append(2*sum(divmod(isqrt(2*x), 2))**2+x)
x *= 4 # Chai Wah Wu, Dec 16 2014
CROSSREFS
KEYWORD
nonn
AUTHOR
Alex Ratushnyak, Nov 07 2014
STATUS
approved