This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.
%I A236564 #44 May 05 2021 13:40:07 %S A236564 1,-1,-4,7,-17,23,-89,7,28,112,448,1792,-4417,5503,22012,-4633,-18532, %T A236564 -74128,-296512,296863,1187452,-1181833,-4727332,4817239,19268956, %U A236564 -17830441,-71321764,94338007,377352028,-9092137,-36368548,-145474192,-581896768,-2327587072,-9310348288 %N A236564 Difference between 2^(2n-1) and the nearest square. %C A236564 The distances of the even powers 2^(2n) to their nearest squares are obviously all zero and therefore skipped. %H A236564 Vincenzo Librandi, <a href="/A236564/b236564.txt">Table of n, a(n) for n = 1..500</a> %F A236564 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 A236564 a(1) = 2^1 - 1^2 = 1. %e A236564 a(2) = 2^3 - 3^2 = -1. %e A236564 a(3) = 2^5 - 6^2 = 32 - 36 = -4. %p A236564 A236564 := proc(n) %p A236564 local x,sq,lo,hi ; %p A236564 x := 2^(2*n-1) ; %p A236564 sq := isqrt(x) ; %p A236564 lo := sq^2 ; %p A236564 hi := (sq+1)^2 ; %p A236564 if abs(x-lo) < abs(x-hi) then %p A236564 x-lo ; %p A236564 else %p A236564 x-hi ; %p A236564 end if; %p A236564 end proc: # _R. J. Mathar_, Mar 13 2014 %t A236564 Table[2^n - Round[Sqrt[2^n]]^2, {n, 1, 79, 2}] (* _Alonso del Arte_, Feb 23 2014 *) %o A236564 (Python) %o A236564 def isqrt(a): %o A236564 sr = 1 << (int.bit_length(int(a)) >> 1) %o A236564 while a < sr*sr: sr>>=1 %o A236564 b = sr>>1 %o A236564 while b: %o A236564 s = sr + b %o A236564 if a >= s*s: sr = s %o A236564 b>>=1 %o A236564 return sr %o A236564 for n in range(47): %o A236564 nn = 2**(2*n+1) %o A236564 a = isqrt(nn) %o A236564 d1 = nn - a*a %o A236564 d2 = (a+1)**2 - nn %o A236564 if d2 < d1: d1 = -d2 %o A236564 print(str(d1), end=',') %Y A236564 Cf. A053188, A201125, A238454. %K A236564 sign,easy %O A236564 1,3 %A A236564 _Alex Ratushnyak_, Feb 23 2014