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-2 of 2 results.

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)

A056007 Difference between 2^n and largest square strictly less than 2^n.

Original entry on oeis.org

1, 1, 3, 4, 7, 7, 15, 7, 31, 28, 63, 23, 127, 92, 255, 7, 511, 28, 1023, 112, 2047, 448, 4095, 1792, 8191, 7168, 16383, 5503, 32767, 22012, 65535, 88048, 131071, 166831, 262143, 296599, 524287, 444943, 1048575, 296863, 2097151, 1187452, 4194303
Offset: 0

Views

Author

Henry Bottomley, Jul 24 2000

Keywords

Comments

Note that this is not a strictly ascending sequence. - Alonso del Arte, Apr 28 2022

Examples

			a(5) = 2^5 - 5^2 =  7;
a(6) = 2^6 - 7^2 = 15.
		

Crossrefs

Programs

  • Mathematica
    Table[2^n - Floor[Sqrt[2^n - Boole[EvenQ[n]]]]^2, {n, 0, 47}] (* Alonso del Arte, Apr 28 2022 *)
  • PARI
    a(n) = if(n%2, sqrtint(1<Kevin Ryde, Oct 12 2022
  • Python
    from math import isqrt
    def a(n): return 2**n - isqrt(2**n-1)**2
    print([a(n) for n in range(43)]) # Michael S. Branicky, Apr 29 2022
    

Formula

a(n) = 2^n - (ceiling(2^(n/2)) - 1)^2 = A000079(n) - (A017912(n) - 1)^2. - Vladeta Jovovic, May 01 2003
a(n) = A071797(A000079(n)). - Michel Marcus, Apr 29 2022
a(n) = 2^n - A357754(n). - Kevin Ryde, Oct 12 2022
Showing 1-2 of 2 results.