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.

User: Luca Petrone

Luca Petrone's wiki page.

Luca Petrone has authored 16 sequences. Here are the ten most recent ones:

A333832 Lexicographically earliest array of distinct positive integers read row by row; a single row consists of integers using together exactly 10 distinct digits.

Original entry on oeis.org

0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 23, 45, 67, 89, 12, 30, 46, 57, 98, 13, 20, 47, 58, 69, 14, 25, 36, 78, 90, 15, 24, 37, 80, 96, 16, 27, 34, 5089, 17, 26, 35, 4089, 18, 29, 40, 53, 76, 19, 28, 43, 56, 70, 21, 38, 49, 60, 75, 31, 42, 50, 68, 79, 32, 41, 59, 6078, 39, 48, 51, 2067, 52, 61, 73, 4098, 54, 62, 71, 3089
Offset: 1

Author

Eric Angelini and Luca Petrone, Apr 07 2020

Comments

The array is finite, by definition: its final row consists of the single integer 9876543210. This sequence starts like A120125 but diverges after a(23) = 47, though the same idea is developped.

Examples

			The first eight rows of the array (and the last one) are:
0 1 2 3 4 5 6 7 8 9
10 23 45 67 89
12 30 46 57 98
13 20 47 58 69
14 25 36 78 90
15 24 37 80 96
16 27 34 5089
17 26 35 4089
...
9876543210
		

Crossrefs

Cf. A120125 (Smallest positive integer not already in the sequence such that digits used are balanced: no digit appears more than 1 times more than any other).
Cf. A050278.

A308094 Arrange distinct numbers in a single square spiral so that the absolute difference between each number and its eight neighbors is unique.

Original entry on oeis.org

1, 2, 4, 8, 13, 21, 10, 31, 17, 34, 52, 26, 45, 68, 41, 66, 97, 131, 57, 96, 50, 139, 69, 114, 165, 83, 219, 107, 168, 102, 158, 221, 136, 198, 265, 166, 3, 237, 309, 386, 183, 261, 140, 349, 240, 319, 411, 270, 363, 179, 461, 322, 426, 279, 381, 488, 6, 364
Offset: 1

Author

Luca Petrone, May 12 2019

Keywords

Comments

Start with 1; always choose smallest number which has not yet appeared.

Examples

			The spiral begins:
.
   673--476--896--714--200--610--848--660--181--831--180
     |                                                 |
   877  125--280--513--393----9--336--481--364----6  658
     |    |                                       |    |
  1085  429    3--166--265--198--136--221--158  488  187
     |    |    |                             |    |    |
   770  554  237   97---66---41---68---45  102  381  647
     |    |    |    |                   |    |    |    |
   232    7  309  131   13----8----4   26  168  279   18
     |    |    |    |    |         |    |    |    |    |
   743  523  386   57   21    1----2   52  107  426  584
     |    |    |    |    |              |    |    |    |
   964   14  183   96   10---31---17---34  219  322   12
     |    |    |    |                        |    |    |
  1182  405  261   50--139---69--114--165---83  461  842
     |    |    |                                  |    |
   765  539  140--349--240--319--411--270--363--179  680
     |    |                                            |
   233    5--685--499---11--572---16--565---19--514---15
		

Crossrefs

A306389 Partial sums of (k-th digit of decimal expansion of Pi multiplied by (-1)^k).

Original entry on oeis.org

-3, -2, -6, -5, -10, -1, -3, 3, -2, 1, -4, 4, -5, 2, -7, -4, -6, -3, -11, -7, -13, -11, -17, -13, -16, -13, -21, -18, -20, -13, -22, -17, -17, -15, -23, -15, -19, -18, -27, -20, -21, -15, -24, -21, -30, -21, -24, -17, -22, -21, -21, -16, -24, -22, -22, -13, -20, -16, -25, -21, -25, -20, -29, -27, -30, -30, -37, -29, -30, -24, -28
Offset: 1

Author

Luca Petrone, Feb 12 2019

Keywords

Comments

a(n) > 0 for n = 8, 10, 12, 14, 16124, 16126, ... and a(n) = 0 for n = 16120, 16161, 16937, ... - Michel Marcus, Feb 13 2019

Crossrefs

Programs

  • Mathematica
    Accumulate@ MapIndexed[(-1)^First[#2]*#1 &, First@ RealDigits[Pi, 10, 71]] (* Michael De Vlieger, Feb 15 2019 *)

Formula

a(n) = Sum_{k=1..n} (-1)^k*A000796(k).
a(n) = Sum_{k=1..floor(n/2)} A099817(k) - Sum_{k=1..floor((n+1)/2)} A099816(k). - Michel Marcus, Feb 16 2019

A305921 Lexicographically earliest sequence of nonnegative integers such that no three points (i,a(i)), (j,a(j)), (n,a(n)) are collinear and no four points (i,a(i)), (j,a(j)), (k,a(k)), (n,a(n)) are on a circle.

Original entry on oeis.org

0, 0, 1, 1, 5, 3, 8, 2, 3, 2, 4, 8, 9, 7, 15, 11, 4, 10, 5, 11, 16, 9, 30, 38, 26, 30, 18, 10, 28, 36, 17, 21, 38, 7, 12, 20, 49, 41, 23, 23, 6, 16, 28, 13, 6, 29, 49, 56, 17, 19, 36, 22, 24, 56, 64, 12, 61, 21, 14, 69, 13, 68, 78, 53, 33, 69, 39, 27, 31, 18
Offset: 1

Author

Luca Petrone, Jun 14 2018

Keywords

Examples

			The sequence starts like A236266, but a(5) cannot be 4, because (1,0), (2,0), (4,1) and (5,4) lie on the same circle.
		

Crossrefs

Programs

  • Mathematica
    a[0] = a[1] = 0; a[2] = 1; a[n_] := a[n] = Module[{i, j, k, l, AB, AC, CD, BC, BD, AD, ok, ok1}, For[l = 0, True, l++, ok = True; For[j = n - 1, ok && j >= 1, j--, For[i = j - 1, ok && i >= 0, i--, ok = (n - j)*(a[j] - a[i]) != (j - i)*(l - a[j])]]; If[ok, For[k = n - 1, ok && k >= 1, k--, For[j = k - 1, ok && j >= 0, j--, For[i = j - 1, ok && i >= 0, i--, AB = ((a[i] - a[j])^2 + (i - j)^2)^0.5; AC = ((a[i] - a[k])^2 + (i - k)^2)^0.5; CD = ((a[k] - l)^2 + (k - n)^2)^0.5; BC = ((a[k] - a[j])^2 + (k - j)^2)^0.5; BD = ((a[j] - l)^2 + (j - n)^2)^0.5; AD = ((a[i] - l)^2 + (i - n)^2)^0.5; ok = AB*CD + BC*AD != AC*BD;];];]; If[ok, Return[l]]]]] (* Luca Petrone Jun 17 2018, based on A236266 program by Jean-François Alcover *)

A280875 Set a(1)=0, a(2)=1, a(3)=3; b(1)=1, b(2)=2; c(1)=3. Thereafter, a(n) is the smallest positive integer m such that m is not yet in sequence a, m-a(n-1) is not yet in sequence b, and m-a(n-2) is not yet in sequence c; set b(n-1)=m-a(n-1), c(n-2)=m-a(n-2).

Original entry on oeis.org

0, 1, 3, 2, 5, 9, 4, 13, 10, 6, 18, 11, 16, 7, 25, 17, 15, 28, 12, 19, 27, 8, 14, 24, 35, 49, 20, 37, 52, 21, 44, 33, 23, 47, 41, 29, 54, 70, 22, 42, 61, 36, 78, 31, 53, 74, 30, 57, 83, 26, 56, 84, 32, 64, 51, 34, 71, 100, 38, 81, 60, 40, 86, 63, 39, 87, 69, 43
Offset: 1

Author

Luca Petrone, May 14 2018

Keywords

Examples

			For n=4: m=2 works, because 2 is not in a, 2-3=-1 is not in b, and 2-1=1 is not in c; set a(4)=2, b(3)=-1 and c(2)=1.
For n=5: m=5 works, because 5 is not in a, 5-2=3 is not in b, and 5-3=2 is not in c; set a(5)=5, b(4)=3 and c(3)=2.
		

Crossrefs

Cf. A257883, A308000 (b), A308001 (c).

Programs

  • Mathematica
    a = {0, 1};
    d1 = {1};
    d2 = {};
    For[n = 3, n <= 10000, n++,
    For[t = Min[Complement[Range[Max[n]], a]], t <= Infinity, t++,
    If[MemberQ[a, t] == False,
    If[MemberQ[d1, t - a[[n - 1]]] == False && MemberQ[d2, t - a[[n - 2]]] == False,Break[];]]];
    a = Flatten[Append[a, t]];
    d1 = Flatten[Append[d1, t - a[[n - 1]]]];
    d2 = Flatten[Append[d2, t - a[[n - 2]]]];]

Extensions

Edited by N. J. A. Sloane, Jun 25 2018.

A297367 Numerators of fraction whose denominator is defined in A303612.

Original entry on oeis.org

0, 1, 1, 1, 2, 1, 3, 2, 3, 6, 1, 1, 1, 2, 1, 2, 3, 1, 2, 3, 1, 3, 2, 3, 4, 1, 5, 3, 5, 2, 3, 4, 6, 1, 10, 6, 4, 7, 3, 7, 2, 7, 5, 3, 4, 5, 6, 7, 10, 17, 1, 18, 11, 8, 7, 6, 5, 4, 7, 10, 3, 11, 5, 12, 7, 11, 19, 2, 13, 9, 7, 5, 13, 8, 14, 3, 13, 10, 7, 11, 4
Offset: 0

Author

Luca Petrone, Apr 30 2018

Keywords

Crossrefs

Cf. A303612.

Programs

  • Maple
    # The function r is defined in A303612.
    a := n -> numer(r(n)): seq(a(n), n=0..99); # Peter Luschny, May 19 2018
  • Mathematica
    a = {1};
    For[i = 1, i <= 100, i++,
    nmax = 10^(Floor[Log[10, i]] + 1);
    r = i/nmax;
    For[n = 1, n <= nmax, n++,
    If[Round[Round[n r]/n, 1/nmax] == r,
    a = Flatten[Append[a, Round[n r]]];
    Break[];
    ]]]

A303612 a(n) = min{denominator(r) with r in R} and R = {0 <= r rational <= 1 and [r*k] = n}. Here k = 10^(floor(log_10(n))+1) and [x] = floor(x+1/2) + ceiling((2*x-1)/4) - floor((2*x-1)/4) - 1.

Original entry on oeis.org

1, 7, 4, 3, 5, 2, 5, 3, 4, 7, 10, 9, 8, 15, 7, 13, 19, 6, 11, 16, 5, 14, 9, 13, 17, 4, 19, 11, 18, 7, 10, 13, 19, 3, 29, 17, 11, 19, 8, 18, 5, 17, 12, 7, 9, 11, 13, 15, 21, 35, 2, 35, 21, 15, 13, 11, 9, 7, 12, 17, 5, 18, 8, 19, 11, 17, 29, 3, 19, 13, 10
Offset: 0

Author

Luca Petrone, Apr 27 2018

Keywords

Comments

a(n) is the smallest denominator of a fraction that, when rounded to d digits after the decimal point, is equal to 0.n, where d is the number of digits of n, and the rounding convention applied is that a number whose fractional part is 1/2 is rounded to the nearest even integer.
a(k-n) = a(n), where k is the first power of 10 exceeding n.
The sequence [A297367(n)/a(n), n = 10^(k-1)..10^(k)-1] is a subsequence of the Farey sequence A006842/A006843 of order ceiling((2/3)*10^k). For example, the terms a(1)..a(9) are the denominators of {1/7, 1/4, 1/3, 2/5, 1/2, 3/5, 2/3, 3/4, 6/7}; this sequence of fractions is a subsequence of the Farey sequence of order ceiling((2/3)*10^1) = 7, i.e., F7 = {0/1, 1/7, 1/6, 1/5, 1/4, 2/7, 1/3, 2/5, 3/7, 1/2, 4/7, 3/5, 2/3, 5/7, 3/4, 4/5, 5/6, 6/7, 1/1}.
With the exception of n in {1, 2, 4, 13, 16}, r(n) = A297367(n)/a(n) is in the Farey series of order n (row n of A006842/A006843). - Peter Luschny, May 19 2018

Examples

			The table below shows the different rational numbers which satisfy the requirements of the definition. The denominators of the first rational number in each row constitute the sequence. Note that the round function is not implemented uniformly in popular software. For example, Mathematica matches our definition, while Maple's round function would return incorrect values.
.
  |                     |  decimal  |     round(10*r)
n | rational numbers r  |   value   | Mathematica | Maple
--+---------------------+-----------+-------------+------
0 | 0/1                 | 0.0000000 |      0      |   0
1 | 1/7, 1/8, 1/9, 1/10 | 0.1428571 |      1      |   1
2 | 1/4, 1/5, 1/6, 2/9  | 0.2500000 |      2      | * 3 *
3 | 1/3, 2/7, 3/10      | 0.3333333 |      3      |   3
4 | 2/5, 3/7, 3/8, 4/9  | 0.4000000 |      4      |   4
5 | 1/2                 | 0.5000000 |      5      |   5
6 | 3/5, 4/7, 5/8, 5/9  | 0.6000000 |      6      |   6
7 | 2/3, 5/7, 7/10      | 0.6666667 |      7      |   7
8 | 3/4, 4/5, 5/6, 7/9  | 0.7500000 |      8      |   8
9 | 6/7, 7/8, 8/9, 9/10 | 0.8571429 |      9      |   9
		

References

  • C. F. Gauss, Theorematis arithmetici demonstratio nova, Societati regiae scientiarum Gottingensis, Vol. XVI., January 15, 1808, pp. 5-7, section 4-5.
  • L. Graham and Donald E. Knuth and Oren Patashnik, Concrete mathematics: a foundation for computer science (Second Edition), Addison-Wesley Publishing Company, 1994, pp. 86-101.
  • Kenneth E. Iverson, A Programming Language, John Wiley And Sons, Inc., 1962 (4th printing 1967), pp. 11-12.
  • Takeo Kamizawa, Note on the Distance to the Nearest Integer, Faculty of Physics, Astronomy and Informatics, Nicolaus Copernicus University, Toruń, Poland, 2016.
  • A. M. Legendre, Théorie des nombres (deuxième édition), 1808.
  • D. Zuras, M. Cowlishaw, R. M. Grow, et al., IEEE Standard for Floating-Point Arithmetic, Std 754(tm)-2008, ISBN 978-0-7381-5753-5, August 28, 2008, p. 16, sections 4.3.1-4.3.3.

Crossrefs

Programs

  • Maple
    r := proc(n) local nint, k, p, q; k := 10^(ilog10(n)+1);
    nint := m -> floor(m + 1/2) + ceil((2*m-1)/4) - floor((2*m-1)/4) - 1;
    for p from 1 to k do for q from p+1 to k do if nint(p*k/q) = n then return p/q fi od od; 0/1 end:
    a := n -> denom(r(n)): seq(a(n), n=0..99); # Peter Luschny, May 19 2018
  • Mathematica
    a = {1};
    For[i = 1, i <= 100, i++,
    nmax = 10^(Floor[Log[10, i]] + 1);
    r = i/nmax;
    For[n = 1, n <= nmax, n++,
    If[Round[Round[n r]/n, 1/nmax] == r,
    a = Flatten[Append[a, n]];
    Break[];
    ]]]

A279909 Number of steps to reach 1 or a cycle in the Collatz-like problem '3x/2' and '(x-1)/2'.

Original entry on oeis.org

0, 2, 1, 3, 3, 3, 2, 8, 3, 4, 4, 7, 4, 6, 3, 11, 9, 6, 4, 15, 5, 12, 5, 11, 8, 6, 5, 7, 7, 14, 4, 18, 11, 10, 10, 11, 7, 9, 5, 11, 16, 6, 6, 15, 13, 12, 6, 17, 12, 9, 9, 11, 7, 11, 6, 19, 8, 8, 8, 11, 15, 14, 5, 24, 19, 14, 11, 13, 11, 13, 11, 16, 12, 8, 8, 10, 10, 10, 6, 16, 11, 17, 17, 18, 7, 26, 7, 24, 16, 11, 14, 13, 13, 15, 7, 23, 18, 14, 13, 23
Offset: 1

Author

Luca Petrone, Apr 11 2017

Keywords

Comments

This Collatz-like problem is as follows: start with any number n. If n is even, divide it by 2 and multiply by 3, otherwise subtract 1 and divide it by 2.
The iteration always reach {1} or the cycles {4, 6, 9} and {16 , 24 , 36 , 54 , 81 , 40 , 60 , 90 , 135 , 67 , 33}.

Crossrefs

Cf. A006577.

Programs

  • Python
    def a(n):
        if n==1: return 0
        l=[n]
        while True:
            if n%2==0: n=(n//2)*3
            else: n = (n - 1)//2
            if not n in l:
                l+=[n]
                if n<2: break
            else: break
        if l[-1]==1: return len(l)-1
        return len(l)
    for n in range(1, 20001):
        print(n, a(n)) # Indranil Ghosh, Apr 13 2017

A284869 Number of n-step 2-dimensional closed self-avoiding paths on triangular lattice, reduced for symmetry, i.e., where rotations and reflections are not counted as distinct.

Original entry on oeis.org

0, 0, 1, 1, 1, 4, 5, 16, 37, 120, 344, 1175, 3807, 13224, 45645, 161705, 575325, 2074088, 7521818, 27502445, 101134999, 374128188
Offset: 1

Author

Luca Petrone, Apr 04 2017

Keywords

Comments

Differs from A057729 beginning at n = 11, since that sequence includes triangular polyominoes with holes.
a(n) is the number of simply connected polyiamonds with perimeter n. - Walter Trump, Nov 29 2023

Crossrefs

Approaches (1/12)*A036418 for increasing n.

Extensions

a(15) from Hugo Pfoertner, Jun 27 2018
a(16)-a(22) from Walter Trump, Nov 29 2023

A284373 Number of distinct planar connected n-polyhexes having a minimal number of vertices.

Original entry on oeis.org

1, 1, 1, 1, 1, 3, 1, 1, 4, 1, 2, 1, 2, 1, 3, 1, 6, 3, 1, 1, 1, 7, 4, 1, 4, 2, 1, 3, 2, 1, 4, 3, 1, 9, 6, 3, 1, 2, 1, 1, 10, 7, 4, 1, 5, 4, 2, 1, 4, 3, 2, 1, 6, 4, 3, 1, 12, 9, 6, 3, 1, 2, 2, 1, 1, 13, 10, 7, 4, 1, 7, 5, 4, 2, 1, 5, 4, 3, 2, 1, 7, 6, 4, 3, 1, 15, 12, 9, 6
Offset: 1

Author

Luca Petrone, Mar 25 2017

Keywords

Crossrefs

Cf. A121149.

Programs

  • Mathematica
    polyhexeQ[{{_Integer, _Integer} .. }] := True
    polyhexeQ[_] := False
    rot[p_?polyhexeQ] := {-Last[#], Plus @@ #} & /@ p
    ref[p_?polyhexeQ] := {-Plus @@ #, Last[#]} & /@ p
    cyclic[p_] := Module[{i = p, ans = {p}},
      While[(i = rot[i]) != p, AppendTo[ans, i]]; ans]
    dihedral[p_?polyhexeQ] := Flatten[{#, ref[#]} & /@ cyclic[p], 1]
    canonical[p_?polyhexeQ] :=
    Sort[Map[(# - {Min[First /@ p], Min[Last /@ p]}) &, p]] allPieces[p_] := Union[canonical /@ dihedral[p]]
    polyhexes[1] := {{{0, 0}}}
    polyhexes[n_] :=
    polyhexes[n] =
      Module[{f, a, b, fig, ans = {}},
       fig = Map[(f = #; Map[({a, b} = #; {f, {a - 1, b - 1}, f, {a + 1, b - 2}, f, {a + 2, b - 1}, f, {a + 1, b + 1}, f, {a - 1, b + 2}, f, {a - 2, b + 1}}) &, f]) &, polyhexes[n - 1]];
       fig = Partition[Partition[Flatten[fig], 2], n];
       f = Union[canonical /@ Select[Union /@ fig, Length[#] == n &]];
       While[f != {},
        ans = {ans, First[f]};
        f = Complement[f, allPieces[First[f]]]];
       Partition[Partition[Flatten[ans], 2], n]]
    coord[z_] := {Re[#], Im[#]} & /@ z
    atoms[p_?polyhexeQ] := Module[{a, b, v, t, u = E^(Pi I/3)}, {{a, b} = #; v = a + b u; coord[{v, v + 1, v + 1 + u, v + 2 u, v + 2 u - 1, v + u - 1}]} & /@ p]
    A = {};
    n = 1;
    While[n <= 386,
    polyhexes[n];
    polyhexes[n] = Part[polyhexes[n], #] & /@ Ordering[Length[Tally[Flatten[atoms[#], 2]]] &  /@ polyhexes[n],     BinCounts[#, {Min[#], Min[#] + 1}][[1]] & [Length[Tally[Flatten[atoms[#], 2]]] &  /@ polyhexes[n]]];
    A = Flatten[{A, Length[#]}] & [Length[Tally[Flatten[atoms[#], 2]]] &  /@ polyhexes[n]];
    Print[A[[n]]];
    n++;]
    (* Luca Petrone, Mar 25 2017, based on a program by Jaime Rangel-Mondragón *)