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.

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.

This page as a plain text file.
%I A341770 #11 Feb 20 2021 11:45:19
%S A341770 1,8,23,34,61,62,97,138,189,248,315,390,473,564,663,770,885,1008,1139,
%T A341770 1278,1425,1580,1743,1914,2093,2280,2475,2678,2889,3108,3335,3570,
%U A341770 3813,4064,4323,4590,4865,5148,5439,5738,6045,6360,6683,7014,7353,7700,8055,8418
%N 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.
%C A341770 If stepping on prime squares is permitted, a(n) = 4*n^2 + 3*n + 1.
%C A341770 For n >= 7, a(n) = 4*n^2 - 9*n + 5 = 4*(n-1)^2 - (n-1), which is A033991(n-1).
%o A341770 (Python)
%o A341770 from sympy import prime, isprime
%o A341770 from math import sqrt, ceil
%o A341770 def neib(m):
%o A341770     if m == 1: L = [4, 6, 8, 2]
%o A341770     else:
%o A341770         n = int(ceil((sqrt(m) - 1.0)/2.0))
%o A341770         z1 = 4*n*n - 4*n + 2; z2 = 4*n*n - 2*n + 1; z3 = 4*n*n + 1
%o A341770         z4 = 4*n*n + 2*n + 1; z5 = 4*n*n + 4*n + 1;
%o A341770         if m == z1:             L = [m + 1, m - 1, m + 8*n - 1, m + 8*n + 1]
%o A341770         elif m > z1 and m < z2: L = [m + 1, m - 8*n + 7, m - 1, m + 8*n + 1]
%o A341770         elif m == z2:           L = [m + 8*n + 3, m + 1, m - 1, m + 8*n + 1]
%o A341770         elif m > z2 and m < z3: L = [m + 8*n + 3, m + 1, m - 8*n + 5, m - 1]
%o A341770         elif m == z3:           L = [m + 8*n + 3, m + 8*n + 5, m + 1, m - 1]
%o A341770         elif m >z3 and m < z4:  L = [m - 1, m + 8*n + 5, m + 1, m - 8*n + 3]
%o A341770         elif m == z4:           L = [m - 1, m + 8*n + 5, m + 8*n + 7, m + 1]
%o A341770         elif m > z4 and m < z5: L = [m - 8*n + 1, m - 1, m + 8*n + 7, m + 1]
%o A341770         elif m == z5:           L = [m - 8*n + 1, m - 1, m + 8*n + 7, m + 1]
%o A341770     return L
%o A341770 print(1)
%o A341770 L_1 = [1]; L_in = [1]; step_max = 60
%o A341770 for step in range(1, step_max + 1):
%o A341770     L = []
%o A341770     for j in range(0, len(L_1)):
%o A341770         m = L_1[j]
%o A341770         if isprime(m) == 0:
%o A341770             for k in range(4):
%o A341770                 m_k = neib(m)[k]
%o A341770                 if m_k not in L_in: L.append(m_k); L_in.append(m_k)
%o A341770     print(max(L))
%o A341770     L_1 = L
%Y A341770 Cf. A341541, A341542, A341672, A033991.
%K A341770 nonn
%O A341770 0,2
%A A341770 _Ya-Ping Lu_, Feb 19 2021