cp's OEIS Frontend

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.

A238454 Difference between 2^(2*n-1) and the next larger square.

This page as a plain text file.
%I A238454 #33 Oct 12 2022 08:59:16
%S A238454 2,1,4,16,17,68,89,356,697,1337,2449,4001,4417,17668,24329,4633,18532,
%T A238454 74128,296512,1186048,1778369,1181833,4727332,18909328,28184177,
%U A238454 17830441,71321764,285287056,381898097,9092137,36368548,145474192,581896768,2327587072,9310348288
%N A238454 Difference between 2^(2*n-1) and the next larger square.
%F A238454 From _Antti Karttunen_, Feb 27 2014: (Start)
%F A238454 a(n) = ceiling(sqrt(2^(2*n-1)))^2 - 2^(2*n-1).
%F A238454 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.
%F A238454 (End)
%e A238454 a(1) = 4 - 2^1 = 2.
%e A238454 a(2) = 9 - 2^3 = 1.
%e A238454 a(3) = 36 - 2^5 = 4.
%t A238454 (Floor[Sqrt[#]]+1)^2-#&/@Table[2^(2n-1),{n,40}] (* _Harvey P. Dale_, Jul 05 2019 *)
%o A238454 (Python)
%o A238454 def isqrt(a):
%o A238454     sr = 1 << (int.bit_length(int(a)) >> 1)
%o A238454     while a < sr*sr:  sr>>=1
%o A238454     b = sr>>1
%o A238454     while b:
%o A238454         s = sr + b
%o A238454         if a >= s*s:  sr = s
%o A238454         b>>=1
%o A238454     return sr
%o A238454 def a(n):
%o A238454     nn = 2**(2*n+1)
%o A238454     s = isqrt(nn)
%o A238454     return (s+1)**2-nn
%o A238454 for n in range(77):  print(str(a(n)), end=',')
%o A238454 (Sage)
%o A238454 def a(n):
%o A238454     return ceil(2^n/sqrt(2))^2 - 2^(2*n-1) # _Ralf Stephan_, Mar 08 2014
%o A238454 (PARI) a(n) = my(r,s=sqrtint(1<<(2*n-1),&r)); 2*s+1-r; \\ _Kevin Ryde_, Oct 12 2022
%Y A238454 Cf. A000079, A056008, A201125, A236564.
%K A238454 nonn,easy
%O A238454 1,1
%A A238454 _Alex Ratushnyak_, Feb 26 2014