login
A238454
Difference between 2^(2*n-1) and the next larger square.
5
2, 1, 4, 16, 17, 68, 89, 356, 697, 1337, 2449, 4001, 4417, 17668, 24329, 4633, 18532, 74128, 296512, 1186048, 1778369, 1181833, 4727332, 18909328, 28184177, 17830441, 71321764, 285287056, 381898097, 9092137, 36368548, 145474192, 581896768, 2327587072, 9310348288
OFFSET
1,1
FORMULA
From Antti Karttunen, Feb 27 2014: (Start)
a(n) = ceiling(sqrt(2^(2*n-1)))^2 - 2^(2*n-1).
For all n, A000035(abs(A201125(n) - A238454(n))) = 1, because if the nearest square at the other side of 2^(2*n-1) is even, then the nearest square at the other side is odd.
(End)
EXAMPLE
a(1) = 4 - 2^1 = 2.
a(2) = 9 - 2^3 = 1.
a(3) = 36 - 2^5 = 4.
MATHEMATICA
(Floor[Sqrt[#]]+1)^2-#&/@Table[2^(2n-1), {n, 40}] (* Harvey P. Dale, Jul 05 2019 *)
PROG
(Python)
def isqrt(a):
sr = 1 << (int.bit_length(int(a)) >> 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
def a(n):
nn = 2**(2*n+1)
s = isqrt(nn)
return (s+1)**2-nn
for n in range(77): print(str(a(n)), end=', ')
(Sage)
def a(n):
return ceil(2^n/sqrt(2))^2 - 2^(2*n-1) # Ralf Stephan, Mar 08 2014
(PARI) a(n) = my(r, s=sqrtint(1<<(2*n-1), &r)); 2*s+1-r; \\ Kevin Ryde, Oct 12 2022
CROSSREFS
KEYWORD
nonn,easy
AUTHOR
Alex Ratushnyak, Feb 26 2014
STATUS
approved