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

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

A341672 a(n) is the number of numbers on the square spiral board such that it takes n steps for them to reach square 1 along the shortest path without stepping on any prime number.

Original entry on oeis.org

1, 4, 7, 5, 9, 8, 12, 10, 14, 23, 29, 32, 35, 38, 46, 47, 52, 59, 65, 64, 67, 76, 78, 84, 90, 91, 94, 100, 106, 110, 111, 110, 119, 126, 131, 137, 139, 138, 143, 153, 154, 144, 152, 144, 152, 156, 170, 195, 193, 193, 192, 198, 203, 215, 215, 209, 216, 222, 225
Offset: 0

Views

Author

Ya-Ping Lu, Feb 17 2021

Keywords

Comments

a(n) is the number of terms in A341541 whose value equals n.
If stepping on prime squares is permitted, a(n) = 4*n. Conjecture: lim_{n->oo} a(n)/n = 4.

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
    print(1)
    L_1 = [1]; L_in = [1]; step_max = 100
    for step in range(1, step_max + 1):
        L = []
        for j in range(0, len(L_1)):
            m = L_1[j]
            if isprime(m) == 0:
                for k in range(4):
                    m_k = neib(m)[k]
                    if m_k not in L_in: L.append(m_k); L_in.append(m_k)
        print(len(L))
        L_1 = L

A344481 Isolated single primes enclosed by four composites on square spiral board of odd numbers.

Original entry on oeis.org

97, 157, 233, 257, 293, 307, 331, 337, 359, 367, 389, 397, 409, 439, 449, 479, 487, 499, 503, 563, 607, 613, 631, 653, 677, 683, 691, 709, 727, 743, 751, 761, 773, 853, 863, 887, 907, 911, 929, 937, 967, 971, 983, 1013, 1069, 1087, 1117, 1181, 1187, 1193, 1201
Offset: 1

Views

Author

Ya-Ping Lu, May 20 2021

Keywords

Examples

			3 is not a term because two of the four neighbors (1, 5, 17 and 21) are primes.
97 is a term because 97 is a prime and all four neighbors (51, 95, 99 and 159) are composites (see the illustration in Links).
		

Crossrefs

Cf. A341542.

Programs

  • Python
    from sympy import prime, isprime; from math import sqrt, ceil
    def neib(m):
        n = int(ceil((sqrt(m)+1.0)/2.0)); L = [m,m,m,m]
        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
        L[0]+=1 if m
    				

A345654 Numbers with five neighboring primes on the hexagonal spiral board of odd numbers.

Original entry on oeis.org

1, 15, 45, 63, 165, 195, 231, 459, 693, 909, 969, 1299, 1785, 2709, 3699, 4131, 4449, 5145, 7041, 8541, 10209, 16065, 20355, 22569, 27489, 28299, 38151, 47745, 49365, 49959, 58479, 77619, 81021, 84651, 87555, 92625, 101115, 104181, 107271, 107349, 108225
Offset: 1

Views

Author

Ya-Ping Lu, Jun 21 2021

Keywords

Comments

All terms in this sequence are composites.
Conjecture: This sequence is infinite and, except 1 and 15, all terms appear in the region between 6*k^2-16*k+11 and 6*k^2-14*k+9 or between 6*k^2-10*k+5 and 6*k^2-8*k+3, where k (>= 1) is the layer number on the hexagonal board.
If the conjecture is true, twin prime conjecture follows.

Examples

			1 is a term because five of its six neighbors (3, 5, 7, 9, 11, and 13) are primes;
45 is a term because five of its six neighbors (17, 19, 43, 47, 83, and 85) are primes.
A hexagonal spiral board of odd numbers <= 169 is illustrated in the figure below, where terms in the sequence are shown in square brackets and primes in parentheses.
.
                 (151)<(149)<-147<--145<--143<--141
                   /                               \
                  /                                 \
               153   (97)<--95<---93<---91<--(89) (139)
                /     /                         \     \
               /     /                           \     \
            155    99    55<--(53)<--51<---49    87  (137)
             /     /     /                   \     \     \
            /     /     /                     \     \     \
        (157) (101)   57    25<--(23)<--21   (47)   85   135
          /     /     /     /             \     \     \     \
         /     /     /     /               \     \     \     \
      159  (103)  (59)   27    (7)<--(5)  (19)  [45]  (83)  133
       /     /     /     /     /       \     \     \     \     \
      /     /     /     /     /         \     \     \     \     \
   161   105   (61)  (29)    9    [1]-->(3)  (17)  (43)   81  (131)
      \     \     \     \     \               /     /     /     /
       \     \     \     \     \             /     /     /     /
     (163) (107)  [63]  (31)  (11)->(13)->[15]  (41)  (79)  129
         \     \     \     \                     /     /     /
          \     \     \     \                   /     /     /
        [165] (109)   65    33--->35-->(37)-->39    77  (127)
            \     \     \                           /     /
             \     \     \                         /     /
           (167)  111   (67)-->69-->(71)->(73)-->75   125
               \     \                                 /
                \     \                               /
               169  (113)->115-->117-->119-->121-->123
		

Crossrefs

Cf. A341542.

Programs

  • Python
    from sympy import isprime; from math import sqrt, ceil
    def neib(m):
        if m == 1: L = [3, 5, 7, 9, 11, 13]
        elif m == 3: L = [17, 19, 5, 1, 13, 15]
        else:
            L = [m for i in range(6)]; n = int(ceil((3+sqrt(6*m+3))/6))
            a0=6*n*n-18*n+15; a1=6*n*n-16*n+11; a2=6*n*n-14*n+9; a3=6*n*n-12*n+7; a4=6*n*n-10*n+5; a5=6*n*n-8*n+3; a6=6*n*n-6*n+1
            p = 0 if m==a0 else 1 if m>a0 and ma1 and ma2 and ma3 and ma4 and ma5 and m
    				

A341770 Largest number m on the square spiral board such that it takes n steps to reach square 1 from square m along the shortest path without stepping on any prime number.

Original entry on oeis.org

1, 8, 23, 34, 61, 62, 97, 138, 189, 248, 315, 390, 473, 564, 663, 770, 885, 1008, 1139, 1278, 1425, 1580, 1743, 1914, 2093, 2280, 2475, 2678, 2889, 3108, 3335, 3570, 3813, 4064, 4323, 4590, 4865, 5148, 5439, 5738, 6045, 6360, 6683, 7014, 7353, 7700, 8055, 8418
Offset: 0

Views

Author

Ya-Ping Lu, Feb 19 2021

Keywords

Comments

If stepping on prime squares is permitted, a(n) = 4*n^2 + 3*n + 1.
For n >= 7, a(n) = 4*n^2 - 9*n + 5 = 4*(n-1)^2 - (n-1), which is A033991(n-1).

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 - 4*n + 2; z2 = 4*n*n - 2*n + 1; z3 = 4*n*n + 1
            z4 = 4*n*n + 2*n + 1; z5 = 4*n*n + 4*n + 1;
            if m == z1:             L = [m + 1, m - 1, m + 8*n - 1, m + 8*n + 1]
            elif m > z1 and m < z2: L = [m + 1, m - 8*n + 7, m - 1, m + 8*n + 1]
            elif m == z2:           L = [m + 8*n + 3, m + 1, m - 1, m + 8*n + 1]
            elif m > z2 and m < z3: L = [m + 8*n + 3, m + 1, m - 8*n + 5, m - 1]
            elif m == z3:           L = [m + 8*n + 3, m + 8*n + 5, m + 1, m - 1]
            elif m >z3 and m < z4:  L = [m - 1, m + 8*n + 5, m + 1, m - 8*n + 3]
            elif m == z4:           L = [m - 1, m + 8*n + 5, m + 8*n + 7, m + 1]
            elif m > z4 and m < z5: L = [m - 8*n + 1, m - 1, m + 8*n + 7, m + 1]
            elif m == z5:           L = [m - 8*n + 1, m - 1, m + 8*n + 7, m + 1]
        return L
    print(1)
    L_1 = [1]; L_in = [1]; step_max = 60
    for step in range(1, step_max + 1):
        L = []
        for j in range(0, len(L_1)):
            m = L_1[j]
            if isprime(m) == 0:
                for k in range(4):
                    m_k = neib(m)[k]
                    if m_k not in L_in: L.append(m_k); L_in.append(m_k)
        print(max(L))
        L_1 = L

A346948 Isolated single primes enclosed by six composites on hexagonal spiral board of odd numbers.

Original entry on oeis.org

211, 257, 277, 331, 509, 563, 587, 647, 653, 673, 683, 709, 751, 757, 839, 853, 919, 983, 997, 1087, 1117, 1123, 1163, 1283, 1433, 1447, 1493, 1531, 1579, 1637, 1733, 1777, 1889, 1913, 1973, 1993, 2179, 2207, 2251, 2273, 2287, 2333, 2357, 2399, 2447, 2467
Offset: 1

Views

Author

Ya-Ping Lu, Aug 08 2021

Keywords

Comments

It seems that more isolated primes, m, appear in regions 6*k^2-16*k+13 <= m <= 6*k^2-14*k+7 and 6*k^2-10*k+7 <= m <= 6*k^2-8*k+1 than the other 4 regions, where k (>= 1) is the layer number on the hexagonal board, which is illustrated in A345654.
Numbers of prime terms appearing in the 6 regions and 6 arms of a 10000-layer hexagonal board, with the 299970001 odd numbers up to 599940001, are:
Region Appearance Arm Appearance
---------------------------------- ---------- ----------------- ----------
6*k^2-18*k+15 <= m <= 6*k^2-16*k+9 2681490 m = 6*k^2-16*k+11 692
6*k^2-16*k+13 <= m <= 6*k^2-14*k+7 3192576 m = 6*k^2-14*k+ 9 551
6*k^2-14*k+11 <= m <= 6*k^2-12*k+5 2681571 m = 6*k^2-12*k+ 7 671
6*k^2-12*k+ 9 <= m <= 6*k^2-10*k+3 2681254 m = 6*k^2-10*k+ 5 545
6*k^2-10*k+ 7 <= m <= 6*k^2- 8*k+1 3191045 m = 6*k^2- 8*k+ 3 721
6*k^2- 8*k+ 5 <= m <= 6*k^2- 6*k-1 2680620 m = 6*k^2- 6*k+ 1 1040

Examples

			3 is not a term because four of the six neighbors (1, 5, 13, 15, 17 and 19) are primes.
211 is a term because 211 is a prime and all six neighbors (145, 147, 209, 213, 287 and 289) are composites.
		

Crossrefs

Programs

  • Python
    from sympy import isprime; from math import sqrt, ceil
    def neib(m):
        if m == 1: return [3, 5, 7, 9, 11, 13]
        if m == 3: return [17, 19, 5, 1, 13, 15]
        L = [m for i in range(6)]; n = int(ceil((3+sqrt(6*m + 3))/6)); x=6*n*n; y=12*n
        a0 = x-18*n+15; a1 =x-16*n+11; a2 =x-14*n+9
        a3 = x-y+7; a4 =x-10*n+5; a5 =x-8*n+3; a6 =x-6*n+1
        p = 0 if m==a0 else 1 if m>a0 and ma1 and ma2 and ma3 and ma4 and ma5 and m
    				
Showing 1-6 of 6 results.