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.
%I A087279 #35 Sep 14 2022 05:23:03 %S A087279 0,2,3,5,8,10,15,17,24,26,35,37,48,50,63,65,80,82,99,101,120,122,143, %T A087279 145,168,170,195,197,224,226,255,257,288,290,323,325,360,362,399,401, %U A087279 440,442,483,485,528,530,575,577,624,626,675,677,728,730,783,785,840 %N A087279 Nonnegative numbers whose distance to the nearest positive square equals exactly 1. %C A087279 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. %H A087279 Reinhard Zumkeller, <a href="/A087279/b087279.txt">Table of n, a(n) for n = 1..10000</a> %H A087279 <a href="/index/Rec#order_05">Index entries for linear recurrences with constant coefficients</a>, signature (1,2,-2,-1,1). %F A087279 a(1) = 0; a(2*k+1) = a(2*k) + 2*k-1; a(2*k) = a(2*k-1) + 2. %F A087279 a(n-1) = floor((n+1)/2)^2+(-1)^(n mod 2). %F A087279 From _Bruno Berselli_, Apr 21 2011: (Start) %F A087279 G.f.: x^2*(2+x-2*x^2+x^3)/((1+x)^2*(1-x)^3). %F A087279 a(n) = (2*n*(n+1) - (2*n-7)*(-1)^n+1)/8. (End) %F A087279 From _Amiram Eldar_, Sep 14 2022: (Start) %F A087279 Sum_{n>=2} 1/a(n) = coth(Pi)*Pi/2 + 1/4. %F A087279 Sum_{n>=2} (-1)^n/a(n) = coth(Pi)*Pi/2 - 5/4. (End) %t A087279 Union[(r = Range[30]^2) - 1, r + 1] (* _Jean-François Alcover_, Oct 25 2013 *) %t A087279 Flatten[#+{1,-1}&/@(Range[30]^2)]//Union (* _Harvey P. Dale_, Oct 15 2016 *) %o A087279 (Magma) &cat[[n^2-1,n^2+1]: n in [1..30]]; // _Bruno Berselli_, Apr 21 2011 %o A087279 (PARI) a(n)=if(n%2,(n+1)^2/4-1,n^2/4+1) \\ _Charles R Greathouse IV_, Apr 25 2012 %o A087279 (Haskell) %o A087279 a087279 n = a087279_list !! (n-1) %o A087279 a087279_list = 0 : 2 : f (drop 2 a000290_list) %o A087279 where f (x:xs) = x-1 : x+1 : f xs %o A087279 -- _Reinhard Zumkeller_, Nov 01 2013 %o A087279 (Python) %o A087279 def A087279(n): return ((n+(b:=n&1))**2>>2)+1-(b<<1) # _Chai Wah Wu_, Aug 03 2022 %Y A087279 Cf. A000290, A004526, A000035, A087278. %Y A087279 Cf. A005563, A002522. %K A087279 nonn,easy %O A087279 1,2 %A A087279 _Reinhard Zumkeller_, Aug 28 2003 %E A087279 _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