login
The OEIS Foundation is supported by donations from users of the OEIS and by a grant from the Simons Foundation.

 

Logo


Hints
(Greetings from The On-Line Encyclopedia of Integer Sequences!)
A087279 Nonnegative numbers such that distance to nearest positive square equals exactly 1. 3
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 (list; graph; refs; listen; history; text; internal format)
OFFSET

1,2

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.

LINKS

Reinhard Zumkeller, Table of n, a(n) for n = 1..10000

Index entries for linear recurrences with constant coefficients, signature (1,2,-2,-1,1).

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).

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  - 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 *)

PROG

(MAGMA) &cat[[n^2-1, n^2+1]: n in [1..30]];  // Bruno Berselli, Apr 21 2011

(PARI) a(n)=if(n%2, (n+1)^2/4-1, n^2/4+1) \\ Charles R Greathouse IV, Apr 25 2012

(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

CROSSREFS

Cf. A000290, A004526, A000035, A087278.

Sequence in context: A022955 A254297 A306972 * A246346 A084907 A158724

Adjacent sequences:  A087276 A087277 A087278 * A087280 A087281 A087282

KEYWORD

nonn,easy

AUTHOR

Reinhard Zumkeller, Aug 28 2003

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

STATUS

approved

Lookup | Welcome | Wiki | Register | Music | Plot 2 | Demos | Index | Browse | More | WebCam
Contribute new seq. or comment | Format | Style Sheet | Transforms | Superseeker | Recent
The OEIS Community | Maintained by The OEIS Foundation Inc.

License Agreements, Terms of Use, Privacy Policy. .

Last modified April 15 18:51 EDT 2021. Contains 342977 sequences. (Running on oeis4.)