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-10 of 11 results. Next

A341541 a(n) is the number of steps to reach square 1 for a walk starting from square n along the shortest path on the square spiral board without stepping on any prime number. a(n) = -1 if such a path does not exist.

Original entry on oeis.org

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

Views

Author

Ya-Ping Lu, Feb 14 2021

Keywords

Comments

Conjecture: There is no "island of two or more nonprimes" enclosed by primes on the square spiral board. If the conjecture is true, then numbers n such that a(n) = -1 are the terms in A341542.

Examples

			The shortest paths for a(n) <= 20 are illustrated in the figure attached in Links section. If more than one path are available, the path through the smallest number is chosen as the shortest path.
		

Crossrefs

Programs

  • Python
    from sympy import prime, isprime
    from math import sqrt, ceil
    def neib(m):
        if m == 1: L = [4, 6, 8, 2]
        else:
            n = int(ceil((sqrt(m) + 1.0)/2.0))
            z1 = 4*n*n - 12*n + 10; z2 = 4*n*n - 10*n + 7; z3 = 4*n*n - 8*n + 5
            z4 = 4*n*n - 6*n + 3; z5 = 4*n*n - 4*n + 1
            if m == z1:             L = [m + 1, m - 1, m + 8*n - 9, m + 8*n - 7]
            elif m > z1 and m < z2: L = [m + 1, m - 8*n + 15, m - 1, m + 8*n - 7]
            elif m == z2:           L = [m + 8*n - 5, m + 1, m - 1, m + 8*n - 7]
            elif m > z2 and m < z3: L = [m + 8*n - 5, m + 1, m - 8*n + 13, m - 1]
            elif m == z3:           L = [m + 8*n - 5, m + 8*n - 3, m + 1, m - 1]
            elif m > z3 and m < z4: L = [m - 1, m + 8*n - 3, m + 1, m - 8*n + 11]
            elif m == z4:           L = [m - 1, m + 8*n - 3, m + 8*n - 1, m + 1]
            elif m > z4 and m < z5: L = [m - 8*n + 9, m - 1, m + 8*n - 1, m + 1]
            elif m == z5:           L = [m - 8*n + 9, m - 1, m + 8*n - 1, m + 1]
        return L
    step_max = 20; L_last = [1]; L2 = L_last; L3 = [[1]]
    for step in range(1, step_max + 1):
        L1 = []
        for j in range(0, len(L_last)):
            m = L_last[j]; k = 0
            while k <= 3 and isprime(m) == 0:
                m_k = neib(m)[k]
                if m_k not in L1 and m_k not in L2: L1.append(m_k)
                k += 1
        L2 += L1; L3.append(L1); L_last = L1
    i = 1
    while i:
        if isprime(neib(i)[0])*isprime(neib(i)[1])*isprime(neib(i)[2])*isprime(neib(i)[3]) == 1: print(-1)
        elif i not in L2: break
        for j in range(0, len(L3)):
            if i in L3[j]: print(j); break
        i += 1

A346294 Numbers with two or more distinct prime factors such that the number and all its prime factors fall on a single straight line when they are plotted on a square spiral.

Original entry on oeis.org

21, 24, 35, 87, 91, 99, 106, 176, 200, 273, 282, 363, 432, 507, 564, 651, 669, 951, 1333, 1445, 1805, 1837, 1963, 2669, 2813, 4163, 4557, 4625, 6321, 6643, 6685, 6723, 7225, 7567, 8333, 10152, 10252, 12826, 12877, 14761, 21409, 23317, 24651, 25337, 27391, 27419, 32039, 34225, 36673, 42029
Offset: 1

Views

Author

Scott R. Shannon, Jul 13 2021

Keywords

Comments

On a spiral spiral plot the position of a number along with all its prime factors, where the number has at least two distinct prime factors. The sequence lists those numbers for which all these points can be connected by a single straight line.
The first term with two prime factors is 21, the first with three is 273, the first with four is 65793, and the first with five is 6118203. Almost all of the later numbers lie on lines with gradient +-1 passing through or very close to the central 1 square. In general there is a concentration of term on these diagonals; see the linked image.
There are 258 terms for numbers below 100 million. In that range the largest prime factor to appear is for 69672413 = 29 * 2402497, where 2402497 has coordinate (-771,775) relative to the central 1 square, 29 is at coordinate (3,1), while the term 69672413 is at coordinate (4174,-4170).

Examples

			The square spiral is numbered as follows:
.
  17--16--15--14--13   .
   |               |   .
  18   5---4---3  12   29
   |   |       |   |   |
  19   6   1---2  11   28
   |   |           |   |
  20   7---8---9--10   27
   |                   |
  21--22--23--24--25--26
.
21 is a term as 21 = 3 * 7, and 21 is at coordinate (-2,-2) relative to the central 1 square, 3 is at coordinate (1,1), and 7 is at coordinate (-1,-1). These three points all fall on the line y = x.
87 is a term as 87 = 3 * 29, and 87 is at coordinate (5,1), 3 is at coordinate (1,1), and 29 is at coordinate (3,1). These three points all fall on the line y = 1.
200 is a term as 200 = 2^3 * 5^2, and 200 is at coordinate (-7,4), 2 is at coordinate (1,0), and 5 is at coordinate (-1,1). These three points all fall on the line y = -x/2 + 1/2.
273 is a term as 271 = 3 * 7 * 13, and 273 is at coordinate (-8,-8), 3 is at coordinate (1,1), 7 is at coordinate (-1,-1), and 13 is at coordinate (2,2). These four points all fall on the line y = x. This is the first term with three distinct prime factors.
65793 is a term as 65793 = 3 * 7 * 13 * 241, and all these points fall on the line y = x. This is the first term with four distinct prime factors.
6118203 is a term as 6118203 = 3 * 7 * 13 * 73 * 307, and all these points fall on the line y = x. This is the first term with five distinct prime factors.
		

Crossrefs

A335710 The smallest number on a square (Ulam) spiral in a 2D grid such that n steps in one of the four axial directions leads to each visited number sharing a common factor greater than 1 with the previous visited number.

Original entry on oeis.org

1, 3, 30, 1235, 2439, 90000, 88805, 4330458, 4322139, 22001763, 21983004, 1868098088, 2436807593
Offset: 0

Views

Author

Scott R. Shannon, Jun 18 2020

Keywords

Comments

Start with any number on a square (Ulam) spiral in a 2D grid and then continue to step right to the next square as long as the number in that square shares a common factor > 1 with the number in the current square. Count the steps one can take. Repeat this process in each of the other three axial directions left, upward and downward, and then take the maximum step length of these four directions. The sequence a(n) gives the smallest number such that the maximum step length of these four directions is n.
If a(13) exists it is greater than 5*10^11.

Examples

			a(0) = 1 as 1 has no common factor > 1 with its neighboring four squares.
a(1) = 3 as stepping right one step from 3 leads to 12 which shares the common factor 3.
a(2) = 30 as stepping right two steps from 30 leads to 55 and 88 which share the common factors 5 and 11 respectively.
a(3) = 1235 as stepping right three steps from 1235 leads to 1380, 1533, 1694 which share the common factors 5, 3, 7 respectively.
a(4) = 2439 as stepping right four steps from 2439 leads to 2640, 2849, 3066, 3291 which share the common factors 3, 11, 7, 3 respectively.
a(5) = 90000 as stepping upward five steps from 90000 leads to 91203, 92414, 93633, 94860, 96095 which share common factors 3, 7, 23, 3, 5 respectively.
a(6) = 88805 as stepping upward one step from 88805 leads to 90000, which shares a common factor 5, and then continues upwards with the same five steps as a(5).
a(7) = 4330458 as stepping downward seven steps from 4330458 leads to 4338785, 4347120, 4355463, 4363814, 4372173, 4380540, 4388915 which share common factors 11, 5, 3, 7, 13, 3, 5 respectively.
a(8) = 4322139 as stepping downward one step from 4322139 leads to 4330458, which shares a common factor 3, and then continue downward with the same seven steps as a(7).
a(9) = 22001763 as stepping downward nine steps from 22001763 leads to 22020530, 22039305, 22058088, 22076879, 22095678, 22114485, 22133300, 22152123, 22170954 which share common factors 7, 5, 3, 19, 11, 3, 5, 7, 3 respectively.
a(10) = 21983004 as stepping downward one step from 21983004 leads to 22001763, which shares a common factor 3, and then continue downward with the same nine steps as a(9).
a(11) = 1868098088 as stepping upward eleven steps from 1868098088 leads to 1868270979, 1868443878, 1868616785, 1868789700, 1868962623, 1869135554, 1869308493, 1869481440, 1869654395, 1869827358, 1870000329 which share common factors 23, 3, 7, 5, 3, 11, 13, 3, 5, 7, 3 respectively.
a(12) = 2436807593 as stepping left twelve steps from 2436807593 leads to 2437005054, 2437202523, 2437400000, 2437597485, 2437794978, 2437992479, 2438189988, 2438387505, 2438585030, 2438782563, 2438980104, 2439177653 which share common factors 11, 3, 7, 5, 3, 23, 13, 3, 5, 7, 3, 11 respectively.
		

Crossrefs

A336494 The number of steps for a walk on a square spiral numbered board when starting on square 1 and stepping to an unvisited square containing the lowest prime number, where the square is within a block of size (2n+1) X (2n+1) centered on the current square. If no unvisited prime numbered squares exist within the block the walk ends.

Original entry on oeis.org

7, 37, 65, 308, 654, 7214, 21992, 49850, 222791, 1146922, 1912101, 6372680, 23077800
Offset: 1

Views

Author

Scott R. Shannon, Jul 23 2020

Keywords

Comments

For n = 1 this sequence is similar to A335856 except that only prime numbers can be stepped to; if no adjacent prime number exists then the walk ends. In general for a(n) the walk can step to any unvisited square containing the lowest prime number within a block of size (2n+1) X (2n+1) centered on the current square.
See A336576 for the final square number of the walks.

Examples

			The board is numbered with the square spiral:
.
  17--16--15--14--13   .
   |               |   .
  18   5---4---3  12   29
   |   |       |   |   |
  19   6   1---2  11   28
   |   |           |   |
  20   7---8---9--10   27
   |                   |
  21--22--23--24--25--26
.
a(1) = 7. Starting from the square 1 the sequence of adjacent unvisited lowest primes the walk can step to are 2,3,11,29,13,31,59. Once the square 59 is visited there are no other unvisited adjacent squares containing primes, so the walk terminates after 7 steps. See the first linked image.
a(2) = 38. This walk also starts by stepping to 2 and then 3. But the next lowest prime 5 is now two units away so is reachable and is thus the next stepped to square. Further steps are 7,19,17,37...,827,829,719,947. Once the square 947 is visited there are no other unvisited squares containing primes within the surrounding 5x5 block of squares, so the walk terminates after 38 steps. See the second linked image.
Also see the linked images for n=3,4,5,6.
		

Crossrefs

Cf. A336576 (final square number), A335856, A000040, A136626, A336092, A330979, A332767, A335661, A335364.

A348022 The numbers visited on a square spiral when stepping to the smallest unvisited number that is visible from and shares a divisor > 1 with the current number. Start with 1 and 2.

Original entry on oeis.org

1, 2, 4, 6, 3, 12, 9, 15, 5, 10, 14, 7, 21, 27, 18, 16, 8, 22, 11, 33, 30, 20, 24, 32, 26, 13, 39, 36, 28, 35, 25, 40, 44, 38, 19, 76, 34, 17, 68, 42, 45, 51, 48, 57, 66, 55, 60, 46, 23, 92, 58, 50, 62, 31, 155, 70, 49, 56, 63, 72, 64, 52, 65, 78, 54, 69, 84, 75, 85, 80, 94, 47, 188
Offset: 1

Views

Author

Scott R. Shannon, Sep 25 2021

Keywords

Comments

A number is visible from the current number if, given it has coordinates (x,y) relative to the current number, the greatest common divisor of |x| and |y| equals 1. See A331400 for the points visible from the starting 1 number.
In the first 10000 terms the longest single step is one at n = 9942 of length sqrt(22570) units between 31002 to 10258. The maximum difference between terms in the same range is from 5171 to 36197 at n = 9977.

Examples

			The square spiral is numbered as follows:
.
  17--16--15--14--13   .
   |               |   .
  18   5---4---3  12   29
   |   |       |   |   |
  19   6   1---2  11   28
   |   |           |   |
  20   7---8---9--10   27
   |                   |
  21--22--23--24--25--26
.
a(3) = 4 as gcd(4,2) = 2 and 4 is unvisited and visible from 2.
a(4) = 6 as gcd(4,6) = 2 and 6 is unvisited and visible from 4.
a(5) = 3 as gcd(3,6) = 3 and 3 is unvisited and visible from 6.
a(6) = 12 as gcd(12,3) = 3 and 12 is unvisited and visible from 3. Note although 9 is unvisited and gcd(9,3) = 3 it is not visible from 3 due to 2.
		

Crossrefs

Cf. A348025 (not visible), A331400, A335661, A063826, A332767, A347358.

A336576 The final square number for a walk on a square spiral numbered board when starting on square 1 and stepping to an unvisited square containing the lowest prime number, where the square is within a block of size (2n+1) x (2n+1) centered on the current square. If no unvisited prime numbered squares exist within the block the walk ends.

Original entry on oeis.org

59, 947, 313, 3331, 5659, 67547, 253801, 676259, 3162413, 16604417, 29135971, 108235159, 437456497
Offset: 1

Views

Author

Scott R. Shannon, Jul 26 2020

Keywords

Comments

See A336494 for an explanation of the sequence and images of the walks.

Examples

			a(1) = 59. Starting from the square 1 the sequence of adjacent unvisited lowest primes the walk can step to are 2,3,11,29,13,31,59. Once the square 59 is visited there are no other unvisited adjacent squares containing primes, so the walk terminates.
		

Crossrefs

Cf. A336494 (total number of steps), A335856, A000040, A136626, A336092, A330979, A332767, A335661, A335364.

A336799 The numbers visited on a square spiral, with a(1)=1, a(2)=2, a(3) = 6, when stepping to an unvisited number as close as possible to the n = 1 starting position that has at least one common factor with the last visited number but none with the second last visited number. In case of a tie, choose the smallest number.

Original entry on oeis.org

1, 2, 6, 15, 35, 14, 12, 33, 77, 28, 10, 45, 21, 56, 20, 55, 99, 18, 34, 85, 75, 24, 22, 143, 39, 30, 46, 161, 63, 36, 40, 95, 57, 42, 26, 65, 105, 48, 38, 247, 117, 69, 115, 70, 44, 187, 51, 54, 52, 91, 119, 68, 60, 87, 203, 98, 62, 93, 129, 86, 76, 133, 175, 50, 78, 141, 235, 80, 58, 261
Offset: 1

Views

Author

Scott R. Shannon, Jan 27 2021

Keywords

Comments

This sequence is the square spiral version of the Enots Wolley sequence A336957. The same rules for selecting the next number apply except that, instead of choosing the smallest unvisited number for a(n), the number closest to the starting n = 1 position which satisfies the selection rules is chosen. If two or more such numbers exist then the smallest is chosen.
The first term that differs from A336957 is a(9) = 77. See the examples below.

Examples

			The square spiral used is:
.
  17--16--15--14--13   .
   |               |   .
  18   5---4---3  12   29
   |   |       |   |   |
  19   6   1---2  11   28
   |   |           |   |
  20   7---8---9--10   27
   |                   |
  21--22--23--24--25--26
.
a(8) = 33 as a(7) = 12 = 2*2*3 and a(6) = 14 = 2*7, thus a(8) must contain 3 or 2 as a factor but not 2 or 7. As a(6) excludes 2 it must contain 3 as a factor, and another prime other than 3. The closest unvisited number to the starting 1 position that satisfies these conditions is 33.
a(9) = 77 as a(8) = 33 = 3*11 and a(7) = 12 = 2*2*3, thus a(9) must contain 3 or 11 as a factor but not 2 or 3. As a(7) excludes 3 it must contain 11 as a factor, and another prime other than 11. The smallest unvisited number satisfying these conditions is 55, which is sqrt(20) ~ 4.47 units from 1. However 77 is unvisited and also satisfies the conditions, and is only 4 units from 1, thus a(9) = 77. This is the first term that differs from A336957.
		

Crossrefs

A348025 The numbers visited on a square spiral when stepping to the smallest unvisited number that is not visible from and shares a divisor > 1 with the current number. Start with 1 and 11.

Original entry on oeis.org

1, 11, 55, 15, 21, 3, 9, 27, 30, 2, 6, 14, 16, 10, 4, 8, 12, 18, 20, 32, 34, 28, 22, 24, 26, 36, 33, 39, 42, 38, 40, 46, 44, 48, 45, 5, 25, 65, 13, 91, 7, 35, 49, 105, 51, 17, 153, 57, 19, 114, 50, 52, 54, 56, 66, 68, 62, 58, 29, 87, 84, 60, 63, 69, 23, 161, 77, 99, 93, 31, 124, 70, 72
Offset: 1

Views

Author

Scott R. Shannon, Sep 25 2021

Keywords

Comments

A number is not visible from the current number if, given it has coordinates (x,y) relative to the current number, the greatest common divisor of |x| and |y| is greater than 1. The sequence has a(2) = 11 as that is the smallest number not visible from a(1) = 1.
In the first 10000 terms the longest single step is one at n = 6888 of length sqrt(22556) units between 22203 to 7389. The maximum difference between terms in the same range is from 3469 to 58973 at n = 9709.

Examples

			The square spiral is numbered as follows:
.
  17--16--15--14--13   .
   |               |   .
  18   5---4---3  12   29
   |   |       |   |   |
  19   6   1---2  11   28
   |   |           |   |
  20   7---8---9--10   27
   |                   |
  21--22--23--24--25--26
.
a(3) = 55 as gcd(55,11) = 11 and 55 is unvisited and not visible from 11, being blocked by 29.
a(4) = 15 as gcd(15,55) = 5 and 15 is unvisited and not visible from 55, being blocked by 13, 14 and 30.
a(5) = 21 as gcd(21,15) = 3 and 21 is unvisited and not visible from 15, being blocked by 6.
		

Crossrefs

A335585 The numbers visited on a square spiral, with a(n) = n for 1 <= n <= 3, when stepping to an unvisited number as close as possible to the n = 1 starting position that has at least one common factor with the second last visited number but none with the last visited number. In case of a tie, choose the smallest number.

Original entry on oeis.org

1, 2, 3, 4, 9, 8, 15, 14, 5, 6, 25, 12, 35, 16, 7, 10, 21, 20, 27, 22, 39, 11, 18, 77, 24, 49, 34, 63, 17, 28, 51, 40, 33, 46, 45, 23, 30, 161, 26, 69, 13, 36, 65, 32, 55, 38, 75, 19, 42, 95, 44, 85, 48, 115, 52, 105, 62, 87, 68, 29, 54, 203, 60, 119, 76, 153, 70, 117, 50, 57, 56, 81, 58, 93
Offset: 1

Views

Author

Scott R. Shannon, Jan 26 2021

Keywords

Comments

This sequence is the square spiral version of the Yellowstone permutation A098550. The same rules for selecting the next number apply except that, instead of choosing the smallest unvisited number for a(n), the number closest to the starting n = 1 position which satisfies the selection rules is chosen. If two or more such numbers exist then the smallest is chosen.
The first term that differs from A098550 is a(23) = 18. See the examples below.

Examples

			The square spiral used is:
.
  17--16--15--14--13   .
   |               |   .
  18   5---4---3  12   29
   |   |       |   |   |
  19   6   1---2  11   28
   |   |           |   |
  20   7---8---9--10   27
   |                   |
  21--22--23--24--25--26
.
a(7) = 15 as a(5) = 9 = 3*3 and a(8) = 8 = 2*2*2, thus a(7) must contain 3 as a factor but not 2. The closest unvisited number to the starting 1 position that satisfies these conditions is 15.
a(23) = 18 as a(21) = 39 = 3*13 and a(22) = 11, thus a(23) must contain 3 or 13 as a factor but not 11. The smallest unvisited number satisfying these conditions is 13, which is sqrt(8) units from 1. However 18 is unvisited and also satisfies the conditions, and is only sqrt(5) units from 1, thus a(23) = 18. This is the first term that differs from A098550.
		

Crossrefs

A346429 Squares visited on a square spiral when stepping to the closest unvisited square that contains a number with a different number of divisors to the number in the current square. If two or more such squares are the same distance from the current square then the one with the smallest number is chosen.

Original entry on oeis.org

1, 2, 9, 8, 7, 6, 5, 4, 3, 12, 11, 10, 25, 24, 23, 22, 45, 46, 47, 48, 49, 26, 50, 51, 52, 27, 28, 29, 30, 13, 14, 32, 31, 56, 55, 54, 53, 86, 127, 126, 85, 84, 83, 82, 81, 80, 79, 78, 77, 76, 115, 114, 75, 74, 43, 42, 21, 20, 19, 18, 17, 16, 15, 61, 34, 60, 33, 59, 58, 92, 57, 90, 89, 88, 87
Offset: 1

Views

Author

Scott R. Shannon, Jul 17 2021

Keywords

Comments

The first term at which a step to a non-adjacent square is required is a(64) = 61; the previous square 15 having neighbors already visited or with four divisors.
The linked images show that the path of visited squares can approach the origin after many terms. For example 44 is not visited until the 973644th step, although 43 and 45 are visited after 54 and 16 steps respectively. It is possible eventually all squares are visited although this is unknown.
In the first 10 million terms the longest step distance between terms is on the 8836645th step, between 1548859 and 1578754, a distance of ~90.2 units.

Examples

			The square spiral is numbered as follows:
.
  17--16--15--14--13   .
   |               |   .
  18   5---4---3  12   29
   |   |       |   |   |
  19   6   1---2  11   28
   |   |           |   |
  20   7---8---9--10   27
   |                   |
  21--22--23--24--25--26
.
a(3) = 9 as a(2) = 2 which has two divisors, and the closest three unvisited squares around 2 are 3, 11 and 9, and of those only 9 has a divisor count not equal to two.
a(10) = 12 as a(9) = 3 which has two divisors, and the closest two unvisited squares around 3 are 12 and 14. Both have more than two divisors but 12 is the smaller so it the square stepped to.
		

Crossrefs

Showing 1-10 of 11 results. Next