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.

Showing 1-4 of 4 results.

A056008 Difference between (smallest square strictly greater than 2^n) and 2^n.

Original entry on oeis.org

3, 2, 5, 1, 9, 4, 17, 16, 33, 17, 65, 68, 129, 89, 257, 356, 513, 697, 1025, 1337, 2049, 2449, 4097, 4001, 8193, 4417, 16385, 17668, 32769, 24329, 65537, 4633, 131073, 18532, 262145, 74128, 524289, 296512, 1048577, 1186048, 2097153, 1778369
Offset: 0

Views

Author

Henry Bottomley, Jul 24 2000

Keywords

Comments

If n is even, a(n) = 2*2^(n/2) + 1, since 2^n = (2^(n/2))^2, and a(n) = (2^(n/2) + 1)^2 - (2^(n/2))^2 = 2*2^(n/2) + 1. - Jean-Marc Rebert, Mar 02 2016
If n is odd, a(n) = 4*a(n-2) or 4*a(n-2) - 4*sqrt(a(n-2) + 2^(n-2)) + 1. - Robert Israel, Mar 02 2016

Examples

			a(5)=6^2-2^5=4; a(6)=9^2-2^6=17
		

Crossrefs

Bisections: A000051, A238454.

Programs

  • Magma
    [(Floor(2^(n/2))+1)^2-2^n : n in [0..50]]; // Vincenzo Librandi, Mar 03 2016
    
  • Maple
    f:= proc(n) local m;
       if n::even then m:= 2*2^(n/2)+1
       else m:= ceil(sqrt(2)*2^((n-1)/2))
       fi;
       m^2-2^n
    end proc:
    map(f, [$0..100]); # Robert Israel, Mar 02 2016
  • Mathematica
    ssg[n_]:=Module[{s=2^n},(1+Floor[Sqrt[s]])^2-s]; Array[ssg,50,0] (* Harvey P. Dale, Aug 22 2015 *)
    Table[((Floor[2^(n/2)] + 1)^2 - 2^n), {n, 0, 50}] (* Vincenzo Librandi, Mar 03 2016 *)
  • Python
    from math import isqrt
    def A056008(n): return (isqrt(m:=1<Chai Wah Wu, Apr 28 2023

Formula

a(n) = (floor(2^(n/2))+1)^2 - 2^n = (A017910(n)+1)^2 - A000079(n). - Vladeta Jovovic, May 01 2003
a(2k) = 2*2^k + 1 = 2*a(2(k-1)) - 1. - Jean-Marc Rebert, Mar 02 2016

A236564 Difference between 2^(2n-1) and the nearest square.

Original entry on oeis.org

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
Offset: 1

Views

Author

Alex Ratushnyak, Feb 23 2014

Keywords

Comments

The distances of the even powers 2^(2n) to their nearest squares are obviously all zero and therefore skipped.

Examples

			a(1) = 2^1 - 1^2 = 1.
a(2) = 2^3 - 3^2 = -1.
a(3) = 2^5 - 6^2 = 32 - 36 = -4.
		

Crossrefs

Programs

  • 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 *)
  • 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=',')

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

A267032 Difference between smallest integer square >= 10^(2*n+1) and 10^(2*n+1).

Original entry on oeis.org

6, 24, 489, 4569, 14129, 147984, 2149284, 25191729, 621806289, 5259630921, 19998666404, 102500044289, 3925449108561, 13071591635856, 42248099518244, 4224809951824400, 43007675962234436, 506034404021388356, 6997839444766224, 699783944476622400
Offset: 0

Views

Author

Gwillim Law, Jan 09 2016

Keywords

Examples

			a(0) = 6 = 4^2 - 10; a(1) = 24 = 32^2 - 1000.
		

Crossrefs

Cf. A238454 (a similar sequence with powers of 2). - Michel Marcus, Jan 17 2016

Programs

  • Maple
    f:= proc(n) local s;
      s:= isqrt(10^(2*n+1));
      if s^2 < 10^(2*n+1) then s:= s+1 fi;
      s^2 - 10^(2*n+1)
    end proc:
    seq(f(n),n=0..40); # Robert Israel, Jan 17 2016
  • Mathematica
    dsis[n_]:=Module[{c=10^(2n+1)},(Floor[Sqrt[c]]+1)^2-c]; Array[dsis,20,0] (* Harvey P. Dale, Apr 27 2019 *)
  • Python
    from math import isqrt
    def A267032(n): return (isqrt(m:=10**((n<<1)+1))+1)**2-m # Chai Wah Wu, Apr 27 2023

Formula

a(n) = A068527(A013715(n)). - Michel Marcus, Jan 17 2016

A362564 a(n) is the largest integer x such that n + 2^x is a square, or -1 if no such number exists.

Original entry on oeis.org

3, 1, 0, 5, 2, -1, 1, 3, 4, -1, -1, 2, -1, 1, 0, 7, 9, -1, -1, 4, 2, -1, 1, 0, -1, -1, -1, 3, -1, -1, -1, 5, 8, 1, 0, 6, -1, -1, -1, -1, 7, -1, -1, -1, 2, -1, 1, 4, 5, -1, -1, -1, -1, -1, -1, 3, 6, -1, -1, 2, -1, 1, 0, 9, 10, -1, -1, 11, -1, -1, -1, -1, 3, -1, -1, -1, 2, -1, 1, 6, -1, -1, -1, 4, -1
Offset: 1

Views

Author

Yifan Xie, Apr 24 2023

Keywords

Comments

a(n) is the maximum integer solution x of the indefinite equation n + 2^x = r^2 where n is a constant and r is a positive integer, or -1 if there are no solutions.
See A247763 for the number of solutions and for further information, references and links about this problem.
If n == 0 (mod 4), we first try x = 0 or 1; when x >= 2, the result can be derived from the result for n/4 (see formula).
If n == 2 (mod 4), the only possible values of x is 1, as otherwise n + 2^x == 2 (mod 4), so nonsquare.
If n == 3 (mod 4), the only possible values of x are 0 and 1, as otherwise n + 2^x == 3 (mod 4), so nonsquare.
If n == 1 (mod 4), or n = 4*k + 1 (k >= 0): we suggest that r = 2*m + 1, 4*k + 1 + 2^x = (2*m + 1)^2, thus k + 2^(x - 2) = m*(m + 1); if k is odd, the only possible values of x is 2 because m*(m + 1) is even.
If n = k^2 (k >= 1), 2^x = (r + k)*(r - k), so 2k must be in the form 2^i - 2^j.
The problem can be solved via reduction to three Mordell curves: n + z^3 = y^2, n + 2z^3 = y^2 or equivalently 4n + (2z)^3 = (2y)^2, n + 4z^3 = y^2 or equivalently 16n + (4z)^3 = (4y)^2, where z := 2^floor(x/3). For a given n, each of these three curves is known to have only a finite number of integer points (y,z), proving that x cannot be unbounded. - Max Alekseyev, Apr 26 2023

Examples

			See COMMENTS section for further proof.
For n = 1, 1 + 2^3 = 9 = 3^2;
for n = 4, 4 + 2^5 = 36 = 6^2;
for n = 7, 7 + 2^1 = 9 = 3^2;
for n = 9, 9 + 2^4 = 25 = 5^2.
		

Crossrefs

Programs

  • Sage
    def a362564(n): return max((3*v-2*k for k in range(3) for z,, in EllipticCurve([0,4^k*n]).integral_points() if z>=1<Max Alekseyev, Apr 26 2023

Formula

a(4*k + 2) = 1 if k + 1 is a square, or -1 otherwise.
a(4*k + 3) = 1 if 4*k + 5 is a square, or 0 is k + 1 is a square and 4*k + 5 is a nonsquare, or -1 otherwise.
a(4*k + 4) = a(k) + 2 if a(k) >= 0, or 0 if 4*k + 1 is a square and a(k) = -1, or -1 otherwise.
a(8*k + 5) = 2 if 8*k + 9 is a square, or -1 otherwise.
a((2^i - 2^j)^2) = i + j + 2 for i,j >= 0.
a(n) > -1 if A247763(n) > 0, or equivalently n is in A051204. - Thomas Scheuerle, May 02 2023
Showing 1-4 of 4 results.