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.

A051213 Numbers of the form 2^x-y^2 >= 0.

Original entry on oeis.org

0, 1, 2, 3, 4, 7, 8, 12, 15, 16, 23, 28, 31, 32, 39, 47, 48, 55, 60, 63, 64, 71, 79, 87, 92, 103, 112, 119, 124, 127, 128, 135, 151, 156, 175, 183, 188, 192, 199, 207, 220, 223, 231, 240, 247, 252, 255, 256, 271, 284, 287, 295, 316, 343, 348, 367, 368, 375, 391, 399, 412, 431, 448
Offset: 1

Views

Author

Keywords

Comments

Is 519 in this sequence? Then this is the value of a(73), else it is 527, after which the sequence goes on with 540, 583, 604, 615, 623, 624,... - M. F. Hasler, Oct 09 2014
From R. J. Mathar, Oct 21 2014: (Start)
519 is not in the sequence. [Proof: Consider 2^x-519=y^2 and both sides modulo 3.
Then 2^x-519 = 1,2,1,2.... (mod 3) for x>=0 and y^2=0,1,1,0,1,1,... (mod 3) for y>=0.
For moduli to match (i.e, both 1), x must be even. Then 2^x is the square of the integer y=2^(x/2). (Note that this reference does not work in integers if x is odd).
The next smaller perfect square is (y-1)^2 = (2^(x/2)-1)^2 = 2^x-2^(1+x/2)+1 .
This must be >=2^x-519 to have a solution, so -2^(1+x/2)+1 >= -519
implies 2^(1+x/2)-1 <= 519, which implies 1+x/2 <= 9.02 and x<=16.
One can check numerically that the range 0<=x<=16 do not form perfect squares 2^x-519.] (End)

Crossrefs

Cf. A201125.

Programs

  • Mathematica
    max = 1000; Clear[f]; f[m_] := f[m] = Select[Table[2^x - y^2, {x, 0, m}, {y, 0, Ceiling[2^(x/2)]}] // Flatten // Union, 0 <= # <= max &]; f[1]; f[m = 2]; While[f[m] != f[m - 1], m++]; Print["m = ", m]; A051213 = f[m] (* Jean-François Alcover, May 13 2017 *)
  • PARI
    is_A051213(n)=!A200522(n) \\ M. F. Hasler, Oct 09 2014

Extensions

More terms from M. F. Hasler, Oct 09 2014

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

Original entry on oeis.org

2, 1, 4, 16, 17, 68, 89, 356, 697, 1337, 2449, 4001, 4417, 17668, 24329, 4633, 18532, 74128, 296512, 1186048, 1778369, 1181833, 4727332, 18909328, 28184177, 17830441, 71321764, 285287056, 381898097, 9092137, 36368548, 145474192, 581896768, 2327587072, 9310348288
Offset: 1

Views

Author

Alex Ratushnyak, Feb 26 2014

Keywords

Examples

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

Crossrefs

Programs

  • Mathematica
    (Floor[Sqrt[#]]+1)^2-#&/@Table[2^(2n-1),{n,40}] (* Harvey P. Dale, Jul 05 2019 *)
  • PARI
    a(n) = my(r,s=sqrtint(1<<(2*n-1),&r)); 2*s+1-r; \\ Kevin Ryde, Oct 12 2022
  • 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
    def a(n):
        nn = 2**(2*n+1)
        s = isqrt(nn)
        return (s+1)**2-nn
    for n in range(77):  print(str(a(n)), end=',')
    
  • Sage
    def a(n):
        return ceil(2^n/sqrt(2))^2 - 2^(2*n-1) # Ralf Stephan, Mar 08 2014
    

Formula

From Antti Karttunen, Feb 27 2014: (Start)
a(n) = ceiling(sqrt(2^(2*n-1)))^2 - 2^(2*n-1).
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.
(End)

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

A095803 Values of r in Wolfram's iteration for sqrt(2).

Original entry on oeis.org

2, 4, 16, 28, 28, 112, 92, 368, 28, 112, 448, 1792, 7168, 28672, 22012, 88048, 352192, 667324, 1186396, 1779772, 1187452, 4749808, 18999232, 28543804, 19268956, 77075824, 308303296, 473963068, 377352028, 1509408112
Offset: 0

Views

Author

Eric W. Weisstein, Jun 07 2004

Keywords

Crossrefs

Cf. A095804.

Formula

Apparently a(n) = 4*A201125(n) for n >= 1. - Hugo Pfoertner, Dec 07 2022
Showing 1-4 of 4 results.