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.

A087279 Nonnegative numbers whose distance to the nearest positive square equals exactly 1.

Original entry on oeis.org

0, 2, 3, 5, 8, 10, 15, 17, 24, 26, 35, 37, 48, 50, 63, 65, 80, 82, 99, 101, 120, 122, 143, 145, 168, 170, 195, 197, 224, 226, 255, 257, 288, 290, 323, 325, 360, 362, 399, 401, 440, 442, 483, 485, 528, 530, 575, 577, 624, 626, 675, 677, 728, 730, 783, 785, 840
Offset: 1

Views

Author

Reinhard Zumkeller, Aug 28 2003

Keywords

Comments

Union of A005563 and A002522\{1}: a(2*k+1) = (k+1)^2 - 1 = A005563(k); a(2*k) = k^2 + 1 = A002522(k); positive square + 1 or positive square - 1.

Crossrefs

Programs

  • Haskell
    a087279 n = a087279_list !! (n-1)
    a087279_list = 0 : 2 : f (drop 2 a000290_list)
       where f (x:xs) = x-1 : x+1 : f xs
    -- Reinhard Zumkeller, Nov 01 2013
    
  • Magma
    &cat[[n^2-1,n^2+1]: n in [1..30]]; // Bruno Berselli, Apr 21 2011
    
  • Mathematica
    Union[(r = Range[30]^2) - 1, r + 1] (* Jean-François Alcover, Oct 25 2013 *)
    Flatten[#+{1,-1}&/@(Range[30]^2)]//Union (* Harvey P. Dale, Oct 15 2016 *)
  • PARI
    a(n)=if(n%2,(n+1)^2/4-1,n^2/4+1) \\ Charles R Greathouse IV, Apr 25 2012
    
  • Python
    def A087279(n): return ((n+(b:=n&1))**2>>2)+1-(b<<1) # Chai Wah Wu, Aug 03 2022

Formula

a(1) = 0; a(2*k+1) = a(2*k) + 2*k-1; a(2*k) = a(2*k-1) + 2.
a(n-1) = floor((n+1)/2)^2+(-1)^(n mod 2).
From Bruno Berselli, Apr 21 2011: (Start)
G.f.: x^2*(2+x-2*x^2+x^3)/((1+x)^2*(1-x)^3).
a(n) = (2*n*(n+1) - (2*n-7)*(-1)^n+1)/8. (End)
From Amiram Eldar, Sep 14 2022: (Start)
Sum_{n>=2} 1/a(n) = coth(Pi)*Pi/2 + 1/4.
Sum_{n>=2} (-1)^n/a(n) = coth(Pi)*Pi/2 - 5/4. (End)

Extensions

Franklin T. Adams-Watters pointed out on Jun 26 2007 that there were problems with the first couple of terms. I have made some changes, so now the definition matches the sequence. But some of the comments may need further minor adjustments. - N. J. A. Sloane, Jun 01 2008

A050271 Numbers k such that k = floor(sqrt(k)*ceiling(sqrt(k))).

Original entry on oeis.org

1, 2, 3, 4, 7, 8, 9, 14, 15, 16, 23, 24, 25, 34, 35, 36, 47, 48, 49, 62, 63, 64, 79, 80, 81, 98, 99, 100, 119, 120, 121, 142, 143, 144, 167, 168, 169, 194, 195, 196, 223, 224, 225, 254, 255, 256, 287, 288, 289, 322, 323, 324, 359, 360, 361, 398, 399, 400
Offset: 1

Views

Author

Benoit Cloitre, May 10 2003

Keywords

Comments

Is a(n) asymptotic to C*n^(3/2) where 1/2 < C < 1?
Consists exactly of numbers of the forms j^2 - 2, j^2 - 1, and j^2. As such, is asymptotic to (1/9)*n^2. - Ivan Neretin, Feb 08 2017

Crossrefs

Programs

  • Maple
    a:=n->floor((n+4)/3)^2+irem(n+1,3)-2:
    seq(a(n),n=1..58); # Lorenzo Sauras Altuzarra, Jan 31 2023
  • Mathematica
    Select[Range@400, Floor[(r = Sqrt@#)*Ceiling@r] == # &] (* Ivan Neretin, Feb 08 2017 *)
    LinearRecurrence[{1,0,2,-2,0,-1,1},{1,2,3,4,7,8,9},60] (* Harvey P. Dale, Aug 10 2025 *)
  • PARI
    isok(n) = floor(sqrt(n)*ceil(sqrt(n))) == n; \\ Michel Marcus, Nov 22 2013
    
  • PARI
    Vec(x*(1 + x + x^2 - x^3 + x^4 - x^5) / ((1 - x)^3*(1 + x + x^2)^2) + O(x^100)) \\ Colin Barker, Feb 09 2017
    
  • Python
    def A050271(n):
        a, b = divmod(n+4,3)
        return a**2+b-2 # Chai Wah Wu, Aug 02 2022

Formula

a(n) = floor((n + 4)/3)^2 + ((n + 1) mod 3) - 2. - Ivan Neretin, Feb 08 2017
From Colin Barker, Feb 09 2017: (Start)
a(n) = a(n-1) + 2*a(n-3) - 2*a(n-4) - a(n-6) + a(n-7) for n > 7.
G.f.: x*(1 + x + x^2 - x^3 + x^4 - x^5) / ((1 - x)^3*(1 + x + x^2)^2).
(End)
From Amiram Eldar, Sep 14 2022: (Start)
Sum_{n>=1} 1/a(n) = 2 + Pi^2/6 - cot(sqrt(2)*Pi)*Pi/(2*sqrt(2)).
Sum_{n>=1} (-1)^(n+1)/a(n) = 1 + Pi^2/12 + cosec(sqrt(2)*Pi)*Pi/(2*sqrt(2)). (End)
a(n) = A087278(n+1) - 1 if n > 0. - Lorenzo Sauras Altuzarra, Jan 31 2023

Extensions

Data corrected by Michel Marcus and Benoit Cloitre, Nov 22 2013
Showing 1-2 of 2 results.