login
a(n) = floor(n*(sqrt(2)-1)).
7

%I #58 Feb 14 2024 17:27:16

%S 0,0,0,1,1,2,2,2,3,3,4,4,4,5,5,6,6,7,7,7,8,8,9,9,9,10,10,11,11,12,12,

%T 12,13,13,14,14,14,15,15,16,16,16,17,17,18,18,19,19,19,20,20,21,21,21,

%U 22,22,23,23,24,24,24,25,25,26,26,26,27,27,28,28,28,29,29,30,30,31,31,31

%N a(n) = floor(n*(sqrt(2)-1)).

%C Old name was: Differences between floor(n*sqrt(2)) and n.

%H G. C. Greubel, <a href="/A097508/b097508.txt">Table of n, a(n) for n = 0..5000</a>

%H Heinz H. Bauschke, Minh N. Dao, and Scott B. Lindstrom, <a href="https://arxiv.org/abs/1804.08880">The Douglas-Rachford algorithm for a hyperplane and a doubleton</a>, arXiv:1804.08880 [math.OC], 2018.

%H Marcel Celaya and Frank Ruskey, <a href="https://arxiv.org/abs/1307.0153">Morphic Words and Nested Recurrence Relations</a>, arXiv preprint arXiv:1307.0153 [math.CO], 2013.

%H Luke Schaeffer, Jeffrey Shallit, and Stefan Zorcic, <a href="https://arxiv.org/abs/2402.08331">Beatty Sequences for a Quadratic Irrational: Decidability and Applications</a>, arXiv:2402.08331 [math.NT], 2024. See pp. 17-18.

%F a(n) = (floor(n / cos(45 degrees))) - n.

%F a(n) = A001951(n) - n. - _R. J. Mathar_, Sep 19 2010

%F a(n) = floor((sqrt(2)-1)*n). [Celaya-Ruskey] - _N. J. A. Sloane_, Nov 14 2013

%F a(2*n) = 2*a(n) + A197879(n). - _Robert Israel_, Aug 21 2014

%p seq(floor(n*sqrt(2)) - n, n = 0 .. 100); # _Robert Israel_, Aug 21 2014

%t Table[Floor[n Sqrt[2]]-n,{n,0,80}] (* _Harvey P. Dale_, Dec 04 2014 *)

%o (PARI) a(n)=sqrtint(2*n^2)-n \\ _Charles R Greathouse IV_, Sep 02 2015

%o (Magma) [Floor(n*Sqrt(2)) - n: n in [0..100]]; // _G. C. Greubel_, Mar 27 2018

%Y Cf. A001951, A197879.

%K easy,nonn

%O 0,6

%A _Odimar Fabeny_, Aug 26 2004

%E Extended by _R. J. Mathar_, Sep 19 2010

%E Definition edited by _Robert Israel_, Aug 21 2014

%E Name changed by _Michel Dekking_, Jul 01 2023