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-5 of 5 results.

A378401 Rectangular array read by descending antidiagonals: (row 1) = u, and for n >= 2, (row n) = u-inverse runlength sequence of u, where u = A006338. See Comments.

Original entry on oeis.org

2, 1, 1, 2, 1, 2, 1, 2, 1, 1, 1, 1, 2, 1, 1, 2, 1, 2, 2, 2, 2, 1, 2, 1, 1, 1, 1, 1, 2, 1, 2, 1, 1, 1, 1, 2, 1, 2, 1, 2, 2, 2, 2, 1, 1, 2, 2, 1, 2, 1, 1, 1, 2, 1, 2, 1, 1, 2, 1, 2, 2, 2, 2, 2, 1, 1, 1, 2, 1, 2, 2, 2, 2, 1, 1, 2, 1, 1
Offset: 1

Views

Author

Clark Kimberling, Dec 21 2024

Keywords

Comments

If u and v are sequences, both consisting of 1's and 2's, we call v an inverse runlength sequence of u if u is the runlength sequence of v. Each u has two inverse runlength sequences, one with first term 1 and the other with first term 2. Consequently, an inverse runlength array, in which each row after the first is an inverse runlength sequence of the preceding row, is determined by its first column. Generally, if the first column is periodic with fundamental period p, then the array has p distinct limiting sequences; otherwise, there is no limiting sequence; however, if a segment, of any length, occurs in a row, then it also occurs in a subsequent row. See A378282 for details and related sequences.

Examples

			The corner of the array begins:
     2  1  2  1  1  2  1  2  1  2  1  1  2  1  2  1  1  2  1
     1  1  2  1  1  2  1  2  2  1  2  2  1  2  2  1  2  1  1
     2  1  2  2  1  2  1  1  2  1  1  2  2  1  2  2  1  1  2
     1  1  2  1  1  2  2  1  2  2  1  2  1  1  2  1  2  2  1
     1  2  1  1  2  1  2  2  1  1  2  1  1  2  2  1  2  2  1
     2  1  1  2  1  2  2  1  2  2  1  1  2  1  2  2  1  2  1
     1  1  2  1  2  2  1  2  2  1  1  2  1  1  2  2  1  2  1
     2  1  2  2  1  2  2  1  1  2  1  1  2  2  1  2  1  1  2
     1  1  2  1  1  2  2  1  2  2  1  1  2  1  2  2  1  2  1
     2  1  2  2  1  2  1  1  2  2  1  2  2  1  1  2  1  2  2
     1  1  2  1  1  2  2  1  2  2  1  2  1  1  2  2  1  2  2
     1  2  1  1  2  1  2  2  1  1  2  1  1  2  2  1  2  2  1
		

Crossrefs

Programs

  • Mathematica
    invRE[seq_, k_] := Flatten[Map[ConstantArray[#[[2]], #[[1]]] &,
        Partition[Riffle[seq, {k, 2 - Mod[k + 1, 2]}, {2, -1, 2}], 2]]];
    row1 = Differences[Table[Floor[n*Sqrt[2]+1/2], {n, 1, 20}]];
    rows = {row1}; col = Take[row1, 12];
    Do[AppendTo[rows, Take[invRE[Last[rows], col[[n]]], Length[row1]]], {n, 2, Length[col]}]
    rows // ColumnForm  (* array *)
    w[n_, k_] := rows[[n]][[k]]; Table[w[n - k + 1, k], {n, 12}, {k, n, 1, -1}] // Flatten (* sequence *)
    (* Peter J. C. Moses, Nov 20 2024 *)

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

Original entry on oeis.org

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, 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, 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
Offset: 1

Views

Author

D. R. Hofstadter, Jul 15 1977

Keywords

Comments

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.
Equals its own "derivative", which is formed by counting the strings of 1's that lie between 2's.
First differences of A001951 (with a different offset). - Philippe Deléham, May 29 2006
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
a(n) = number of repeating n's in A049472. - Reinhard Zumkeller, Jul 03 2015
Fixed point of the morphism 1 -> 12; 2 -> 121. - Jeffrey Shallit, Jan 19 2017
Also, let S be the increasing sequence of elements of the union N U N*sqrt(2), where N = {1, 2, 3, ...}. Then a(n) = { 1 if S(n) is integer, 2 if S(n) is irrational }. See A245222 for the analog with sqrt(3). - M. F. Hasler, Feb 06 2025

References

  • Douglas Hofstadter, "Fluid Concepts and Creative Analogies", Chapter 1: "To seek whence cometh a sequence".
  • N. J. A. Sloane and Simon Plouffe, The Encyclopedia of Integer Sequences, Academic Press, 1995 (includes this sequence).

Crossrefs

Cf. A006338. Exchanging 1's and 2's gives A080763. Essentially same as A004641 + 1.
Cf. A049472.
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
Cf. A245222 (an analog with sqrt(3) instead of sqrt(2)).

Programs

  • Haskell
    a006337 n = a006337_list !! (n-1)
    a006337_list = f [1] where
       f xs = ys ++ f ys where
              ys = concatMap (\z -> if z == 1 then [1,2] else [1,1,2]) xs
    -- Reinhard Zumkeller, May 06 2012
    
  • Maple
    Digits := 100; sq2 := sqrt(2.); A006337 := n->floor((n+1)*sq2)-floor(n*sq2);
  • Mathematica
    Flatten[ Table[ Nest[ Flatten[ # /. {1 -> {1, 2}, 2 -> {1, 1, 2}}] &, {1}, n], {n, 5}]] (* Robert G. Wilson v, May 06 2005 *)
    Differences[ Table[ Floor[ n*Sqrt[2]], {n, 1, 106}]] (* Jean-François Alcover, Apr 06 2012 *)
  • PARI
    a(n)=sqrt(2)*(n+1)\1-sqrt(2)*n\1 \\ Charles R Greathouse IV, Apr 06 2012
    
  • PARI
    a(n)=sqrtint(2*n^2+4*n+2)-sqrtint(2*n^2) \\ Charles R Greathouse IV, Apr 06 2012
    
  • Python
    from math import isqrt
    def A006337(n): return -isqrt(m:=n*n<<1)+isqrt(m+(n<<2)+2) # Chai Wah Wu, Aug 03 2022

Formula

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
a(A003152(n)) = 1 and a(A003151(n)) = 2. - Philippe Deléham, May 29 2006
a(n) = A159684(n-1) + 1. - Filip Zaludek, Oct 28 2016

A022846 Nearest integer to n*sqrt(2).

Original entry on oeis.org

0, 1, 3, 4, 6, 7, 8, 10, 11, 13, 14, 16, 17, 18, 20, 21, 23, 24, 25, 27, 28, 30, 31, 33, 34, 35, 37, 38, 40, 41, 42, 44, 45, 47, 48, 49, 51, 52, 54, 55, 57, 58, 59, 61, 62, 64, 65, 66, 68, 69, 71, 72, 74, 75, 76, 78, 79, 81, 82, 83, 85, 86, 88, 89, 91, 92, 93, 95, 96
Offset: 0

Views

Author

Keywords

Comments

Let R(i,j) be the rectangle with antidiagonals 1; 2,3; 4,5,6; ...; n^2 is in antidiagonal number a(n). Proof: n^2 is in antidiagonal m iff A000217(m-1)< n^2 <=A000217(m), where A000217(m)=m*(m+1)/2. So m = A002024(n^2) = round(n*sqrt(2)) = a(n). - Antonio G. Astudillo (afg_astudillo(AT)hotmail.com), Mar 07 2003
In the rectangle R(i,j), n^2 is the number in row i=A057049(n) and column j=A057050(n), so that for n >= 1, a(n) = -1 + A057049(n) + A057050(n). - Clark Kimberling, Jan 31 2011
Number of triangular numbers less than n^2. - Philippe Deléham, Mar 08 2013

Examples

			n = 4, n^2 = 16; 0, 1, 3, 6, 10, 15 are triangular numbers in interval [0, 16); a(4) = 6. - _Philippe Deléham_, Mar 08 2013
		

Crossrefs

Cf. A063957 (complement of this set).
Cf. A214848 (first differences), also A006338.

Programs

  • Haskell
    a022846 = round . (* sqrt 2) . fromIntegral
    -- Reinhard Zumkeller, Mar 03 2014
    
  • Magma
    [Round(n*Sqrt(2)): n in [0..60]]; // Vincenzo Librandi, Oct 22 2011
    
  • Mathematica
    Round[Sqrt[2]Range[0,70]] (* Harvey P. Dale, Jun 18 2013 *)
  • PARI
    a(n)=round(n*sqrt(2))
    
  • Python
    from math import isqrt
    def A022846(n): return isqrt(n**2<<3)+1>>1 # Chai Wah Wu, Feb 10 2023

Formula

a(n) = A002024(n^2).
a(n+1) - a(n) = 1 or 2. - Philippe Deléham, Mar 08 2013

A214848 First difference of A022846.

Original entry on oeis.org

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, 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, 2, 1, 2, 1, 1, 2, 1, 2, 1, 2, 1, 1, 2, 1, 2, 1
Offset: 0

Views

Author

Philippe Deléham, Mar 08 2013

Keywords

Comments

Number of triangular numbers in interval [n^2, (n+1)^2).
From Michel Dekking, Sep 20 2022: (Start)
(a(n)) is an inhomogeneous Sturmian sequence s(alpha, rho) with slope alpha = sqrt(2) and intercept 1/2, since A022846(n) = floor(n*sqrt(2) + 1/2).
(a(n)) is the fixed point of the morphism 1->12121, 2->1212121.
This is proved by writing the 0-1 version psi: 0->01010, 1->0101010 of this morphism as a composition
psi = psi_1 psi_3 psi_1 psi_4,
where the psi_i are the three elementary Sturmian morphisms
psi_1: 0->01, 1->0, psi_3: 0->0, 1->01, psi_4: 0->0, 1->10.
By Lemma 2.2.18 in Lothaire it then follows that the 0-1 word (a(n)-1) = A214848 is fixed by the morphism psi (note that in Lothaire psi_1 is phi, psi_3 is G, and psi_4 is G^~). (End)

Examples

			28 is in [25, 36), a(5) = 1.
36 and 45 are in [36, 49), a(6) = 2.
		

References

  • S.-I. Yasutomi, On Sturmian sequences which are invariant under some substitutions, in Number theory and its applications (Kyoto, 1997), pp. 347-373, Kluwer Acad. Publ., Dordrecht, 1999.

Crossrefs

Programs

  • Haskell
    a214848 n = a214848_list !! n
    a214848_list = zipWith (-) (tail a022846_list) a022846_list
    -- Reinhard Zumkeller, Mar 03 2014
  • Mathematica
    Differences[Round[Sqrt[2]Range[0,100]]] (* Harvey P. Dale, Jun 14 2020 *)

Formula

For n > 0: a(n) = A006338(n). - Reinhard Zumkeller, Mar 03 2014

A106802 Trajectory of 2 under the morphism 1->{2, 1, 2, 1, 1, 2, 2, 1}, 2->{1, 1, 1, 2, 2, 1, 2}.

Original entry on oeis.org

2, 1, 2, 1, 1, 2, 2, 1, 2, 1, 2, 1, 1, 2, 2, 1, 2, 1, 2, 1, 1, 2, 2, 1, 1, 1, 1, 2, 2, 1, 2, 1, 1, 1, 2, 2, 1, 2, 2, 1, 2, 1, 1, 2, 2, 1, 1, 1, 1, 2, 2, 1, 2, 1, 1, 1, 2, 2, 1, 2, 2, 1, 2, 1, 1, 2, 2, 1, 1, 1, 1, 2, 2, 1, 2, 2, 1, 2, 1, 1, 2, 2, 1, 2, 1, 2, 1, 1, 2, 2, 1, 1, 1, 1, 2, 2, 1, 2, 1, 1, 1, 2, 2, 1, 2
Offset: 0

Views

Author

Roger L. Bagula, May 17 2005

Keywords

References

  • T. S. Blyth and E. F. Robertson, Essential Student Algebra: volume 5: Groups: Chapman and Hall, 1986, page 9.

Crossrefs

Programs

  • Mathematica
    s[1, 1] = {1}; s[2, 1] = {2};; s[1, 2] = {2}; s[2, 2] = {1};; s[1, 3] = {1, 2}; s[2, 3] = {1};; s[1, 4] = {1}; s[2, 4] = {1, 2};; s[1, 5] = {1, 2}; s[2, 5] = {2};; s[1, 6] = {2}; s[2, 6] = {1};; w[i_] = s[1, 1 + Mod[i, 6]] v[i_] = s[2, 1 + Mod[i, 6]] S[1] = Flatten[Table[w[i], {i, 1, 6}]] S[2] = Flatten[Table[v[i], {i, 1, 6}]] t[a_] := Flatten[S /@ a]; p[0] = {1}; p[1] = t[p[0]]; p[n_] := t[p[n - 1]] aa = p[3]
    Nest[Flatten[#]/.{1->{2,1,2,1,1,2,2,1},2->{1,1,1,2,2,1,2}}&,2,4]//Flatten (* Harvey P. Dale, Apr 09 2019 *)

Extensions

Edited by N. J. A. Sloane, Nov 12 2006
Showing 1-5 of 5 results.