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