%I #44 May 05 2021 13:40:07
%S 1,-1,-4,7,-17,23,-89,7,28,112,448,1792,-4417,5503,22012,-4633,-18532,
%T -74128,-296512,296863,1187452,-1181833,-4727332,4817239,19268956,
%U -17830441,-71321764,94338007,377352028,-9092137,-36368548,-145474192,-581896768,-2327587072,-9310348288
%N Difference between 2^(2n-1) and the nearest square.
%C The distances of the even powers 2^(2n) to their nearest squares are obviously all zero and therefore skipped.
%H Vincenzo Librandi, <a href="/A236564/b236564.txt">Table of n, a(n) for n = 1..500</a>
%F If A201125(n) < A238454(n), a(n) = A201125(n), otherwise a(n) = -A238454(n). [Negative terms are for cases where the nearest square is above 2^(2n-1), not below it.] - _Antti Karttunen_, Feb 27 2014
%e a(1) = 2^1 - 1^2 = 1.
%e a(2) = 2^3 - 3^2 = -1.
%e a(3) = 2^5 - 6^2 = 32 - 36 = -4.
%p A236564 := proc(n)
%p local x,sq,lo,hi ;
%p x := 2^(2*n-1) ;
%p sq := isqrt(x) ;
%p lo := sq^2 ;
%p hi := (sq+1)^2 ;
%p if abs(x-lo) < abs(x-hi) then
%p x-lo ;
%p else
%p x-hi ;
%p end if;
%p end proc: # _R. J. Mathar_, Mar 13 2014
%t Table[2^n - Round[Sqrt[2^n]]^2, {n, 1, 79, 2}] (* _Alonso del Arte_, Feb 23 2014 *)
%o (Python)
%o def isqrt(a):
%o sr = 1 << (int.bit_length(int(a)) >> 1)
%o while a < sr*sr: sr>>=1
%o b = sr>>1
%o while b:
%o s = sr + b
%o if a >= s*s: sr = s
%o b>>=1
%o return sr
%o for n in range(47):
%o nn = 2**(2*n+1)
%o a = isqrt(nn)
%o d1 = nn - a*a
%o d2 = (a+1)**2 - nn
%o if d2 < d1: d1 = -d2
%o print(str(d1), end=',')
%Y Cf. A053188, A201125, A238454.
%K sign,easy
%O 1,3
%A _Alex Ratushnyak_, Feb 23 2014