login
The OEIS is supported by the many generous donors to the OEIS Foundation.

 

Logo
Hints
(Greetings from The On-Line Encyclopedia of Integer Sequences!)
A236564 Difference between 2^(2n-1) and the nearest square. 3
1, -1, -4, 7, -17, 23, -89, 7, 28, 112, 448, 1792, -4417, 5503, 22012, -4633, -18532, -74128, -296512, 296863, 1187452, -1181833, -4727332, 4817239, 19268956, -17830441, -71321764, 94338007, 377352028, -9092137, -36368548, -145474192, -581896768, -2327587072, -9310348288 (list; graph; refs; listen; history; text; internal format)
OFFSET
1,3
COMMENTS
The distances of the even powers 2^(2n) to their nearest squares are obviously all zero and therefore skipped.
LINKS
FORMULA
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
EXAMPLE
a(1) = 2^1 - 1^2 = 1.
a(2) = 2^3 - 3^2 = -1.
a(3) = 2^5 - 6^2 = 32 - 36 = -4.
MAPLE
A236564 := proc(n)
local x, sq, lo, hi ;
x := 2^(2*n-1) ;
sq := isqrt(x) ;
lo := sq^2 ;
hi := (sq+1)^2 ;
if abs(x-lo) < abs(x-hi) then
x-lo ;
else
x-hi ;
end if;
end proc: # R. J. Mathar, Mar 13 2014
MATHEMATICA
Table[2^n - Round[Sqrt[2^n]]^2, {n, 1, 79, 2}] (* Alonso del Arte, Feb 23 2014 *)
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
for n in range(47):
nn = 2**(2*n+1)
a = isqrt(nn)
d1 = nn - a*a
d2 = (a+1)**2 - nn
if d2 < d1: d1 = -d2
print(str(d1), end=', ')
CROSSREFS
Sequence in context: A349610 A216552 A034736 * A302549 A023860 A009881
KEYWORD
sign,easy
AUTHOR
Alex Ratushnyak, Feb 23 2014
STATUS
approved

Lookup | Welcome | Wiki | Register | Music | Plot 2 | Demos | Index | Browse | More | WebCam
Contribute new seq. or comment | Format | Style Sheet | Transforms | Superseeker | Recents
The OEIS Community | Maintained by The OEIS Foundation Inc.

License Agreements, Terms of Use, Privacy Policy. .

Last modified April 25 05:18 EDT 2024. Contains 371964 sequences. (Running on oeis4.)