login
An "eta-sequence": a(n) = floor( (n+1)*sqrt(2) ) - floor( n*sqrt(2) ).
(Formerly M0086)
35

%I M0086 #81 Aug 05 2022 19:21:57

%S 1,2,1,2,1,1,2,1,2,1,1,2,1,2,1,2,1,1,2,1,2,1,1,2,1,2,1,2,1,1,2,1,2,1,

%T 1,2,1,2,1,1,2,1,2,1,2,1,1,2,1,2,1,1,2,1,2,1,2,1,1,2,1,2,1,1,2,1,2,1,

%U 1,2,1,2,1,2,1,1,2,1,2,1,1,2,1,2,1,2,1,1,2,1,2,1,1,2,1,2,1,2,1,1,2,1,2,1,1

%N An "eta-sequence": a(n) = floor( (n+1)*sqrt(2) ) - floor( n*sqrt(2) ).

%C Defined by: (i) a(1) = 1; (ii) sequence consists of single 2's separated by strings of 1's; (iii) the sequence of lengths of runs of 1's in the sequence is equal to the sequence.

%C Equals its own "derivative", which is formed by counting the strings of 1's that lie between 2's.

%C First differences of A001951 (with a different offset). - _Philippe Deléham_, May 29 2006

%C Or number of perfect squares in interval (2*n^2, 2*(n+1)^2). In view of the uniform distribution mod 1 of sequence {sqrt(2)*n}, the density of 1's is 2-sqrt(2). - _Vladimir Shevelev_, Aug 05 2011

%C a(n) = number of repeating n's in A049472. - _Reinhard Zumkeller_, Jul 03 2015

%C Fixed point of the morphism 1 -> 12; 2 -> 121. - _Jeffrey Shallit_, Jan 19 2017

%D Douglas Hofstadter, "Fluid Concepts and Creative Analogies", Chapter 1: "To seek whence cometh a sequence".

%D N. J. A. Sloane and Simon Plouffe, The Encyclopedia of Integer Sequences, Academic Press, 1995 (includes this sequence).

%H T. D. Noe, <a href="/A006337/b006337.txt">Table of n, a(n) for n = 1..10000</a>

%H F. M. Dekking, <a href="http://www.digizeitschriften.de/dms/resolveppn/?PPN=GDZPPN002544490">On the structure of self-generating sequences</a>, Seminar on Number Theory, 1980-1981 (Talence, 1980-1981), Exp. No. 31, 6 pp., Univ. Bordeaux I, Talence, 1981. Math. Rev. 83e:10075.

%H D. R. Hofstadter, <a href="/A006336/a006336_1.pdf">Eta-Lore</a> [Cached copy, with permission]

%H D. R. Hofstadter, <a href="/A006336/a006336_2.pdf">Pi-Mu Sequences</a> [Cached copy, with permission]

%H D. R. Hofstadter and N. J. A. Sloane, <a href="/A006336/a006336.pdf">Correspondence, 1977 and 1991</a>

%H C. Kimberling, <a href="http://www.jstor.org/stable/2322043">Problem 6281</a>, Amer. Math. Monthly 86 (1979), no. 9, 793.

%H N. J. A. Sloane, <a href="/A115004/a115004.txt">Families of Essentially Identical Sequences</a>, Mar 24 2021 (Includes this sequence)

%F Let S(0) = 1; obtain S(k) from S(k-1) by applying 1 -> 12, 2 -> 112; sequence is S(0), S(1), S(2), ... - _Matthew Vandermast_, Mar 25 2003

%F a(A003152(n)) = 1 and a(A003151(n)) = 2. - _Philippe Deléham_, May 29 2006

%F a(n) = A159684(n-1) + 1. - _Filip Zaludek_, Oct 28 2016

%p Digits := 100; sq2 := sqrt(2.); A006337 := n->floor((n+1)*sq2)-floor(n*sq2);

%t Flatten[ Table[ Nest[ Flatten[ # /. {1 -> {1, 2}, 2 -> {1, 1, 2}}] &, {1}, n], {n, 5}]] (* _Robert G. Wilson v_, May 06 2005 *)

%t Differences[ Table[ Floor[ n*Sqrt[2]], {n, 1, 106}]] (* _Jean-François Alcover_, Apr 06 2012 *)

%o (PARI) a(n)=sqrt(2)*(n+1)\1-sqrt(2)*n\1 \\ _Charles R Greathouse IV_, Apr 06 2012

%o (PARI) a(n)=sqrtint(2*n^2+4*n+2)-sqrtint(2*n^2) \\ _Charles R Greathouse IV_, Apr 06 2012

%o (Haskell)

%o a006337 n = a006337_list !! (n-1)

%o a006337_list = f [1] where

%o f xs = ys ++ f ys where

%o ys = concatMap (\z -> if z == 1 then [1,2] else [1,1,2]) xs

%o -- _Reinhard Zumkeller_, May 06 2012

%o (Python)

%o from math import isqrt

%o def A006337(n): return -isqrt(m:=n*n<<1)+isqrt(m+(n<<2)+2) # _Chai Wah Wu_, Aug 03 2022

%Y Cf. A006338. Exchanging 1's and 2's gives A080763. Essentially same as A004641 + 1.

%Y Cf. A049472.

%Y The following sequences are all essentially the same, in the sense that they are simple transformations of each other, with A003151 as the parent: A003151, A001951, A001952, A003152, A006337, A080763, A082844 (conjectured), A097509, A159684, A188037, A245219 (conjectured), A276862. - _N. J. A. Sloane_, Mar 09 2021

%K nonn,easy,nice

%O 1,2

%A D. R. Hofstadter, Jul 15 1977