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.

A332582 Label the cells of the infinite 2D square lattice with the square spiral (or Ulam spiral), starting with 1 at the center; sequence lists primes that are visible from square 1.

This page as a plain text file.
%I A332582 #27 Feb 16 2025 08:33:59
%S A332582 2,3,5,7,29,41,47,83,89,97,103,107,109,113,173,179,181,191,193,199,
%T A332582 223,293,311,317,347,353,359,443,449,457,461,467,479,487,491,499,503,
%U A332582 509,521,523,631,641,643,647,653,659,661,673,683,691,701,709,719,727,857,863,887,929,947,953,1091
%N A332582 Label the cells of the infinite 2D square lattice with the square spiral (or Ulam spiral), starting with 1 at the center; sequence lists primes that are visible from square 1.
%C A332582 Any grid point with relative coordinates (x,y) from the central grid point, which is numbered 1, and where the greatest common divisor (gcd) of |x| and |y| equals 1 will be visible from the central point. Grid points where gcd(|x|,|y|) > 1 will have another point directly between it and the central point and will thus not be visible. In an infinite 2D square lattice the ratio of visible grid points to all points is 6/Pi^2, approximately 0.608, the same as the probability of two random numbers being relative prime.
%C A332582 For a square spiral of size 10001 X 10001, slightly over 100 million numbers, a total of 60803664 numbers are visible, of which 2155170 are prime. The total number of primes in the same range is 5762536, giving a ratio of visible primes to all primes of about 0.374. This is significantly lower than the ratio for all numbers of 0.608, indicating a prime is more likely to be hidden from the origin than a random number.
%C A332582 Primes p such that A174344(p) and A268038(p) are coprime. - _Robert Israel_, Feb 16 2024
%H A332582 Robert Israel, <a href="/A332582/b332582.txt">Table of n, a(n) for n = 1..10000</a>
%H A332582 Scott R. Shannon, <a href="/A332582/a332582.png">Image showing the visible primes from point 1 for the first 100000 grid points</a>. The visible primes are highlighted in yellow while the hidden primes are highlighted in red. The central 1 square is white while the nonprimes are gray. Zoom into the image to see the grid point numbers.
%H A332582 Eric Weisstein's World of Mathematics, <a href="https://mathworld.wolfram.com/VisiblePoint.html">Visible Point</a>.
%H A332582 Wikipedia, <a href="https://en.wikipedia.org/wiki/Ulam_spiral">Ulam Spiral</a>.
%e A332582 The 2D grid is shown below. Composite numbers are shown as a '*'. The primes that are blocked from the central 1 square are in parentheses; these all have another composite or prime number directly between their position and the central square.
%e A332582 .
%e A332582 .
%e A332582     *----*----*--(61)---*--(59)---*----*
%e A332582                                        |
%e A332582   (37)---*----*----*----*----*--(31)   *
%e A332582     |                             |    |
%e A332582     *  (17)---*----*----*--(13)   *    *
%e A332582     |    |                   |    |    |
%e A332582     *    *    5----*----3    *   29    *
%e A332582     |    |    |         |    |    |    |
%e A332582     *  (19)   *    1----2  (11)   *  (53)
%e A332582     |    |    |              |    |    |
%e A332582    41    *    7----*----*----*    *    *
%e A332582     |    |                        |    |
%e A332582     *    *----*--(23)---*----*----*    *
%e A332582     |                                  |
%e A332582   (43)---*----*----*---47----*----*----*
%e A332582 .
%e A332582 .
%e A332582 a(1) = 2 to a(4) = 7 are all primes adjacent to the central 1 point, thus all are visible from that square.
%e A332582 a(5) = 29 as primes 11, 13, 17, 19, 23 are blocked from the central 1 point by points numbered 2, 3, 5, 6, 8 respectively.
%p A332582 x:= 0: y:= 0: R:= NULL: count:= 0:
%p A332582 for i from 2 while count < 100 do
%p A332582   if x >= y then
%p A332582     if x < -y + 1 then x:= x+1
%p A332582     elif x > y then y:= y+1
%p A332582     else x:= x-1
%p A332582     fi
%p A332582   elif x <= -y then y:= y-1
%p A332582     else x:= x-1
%p A332582   fi;
%p A332582   if isprime(i) and igcd(abs(x),abs(y))=1 then R:= R,i; count:= count+1 fi
%p A332582 od:
%p A332582 R; # _Robert Israel_, Feb 16 2024
%Y A332582 Cf. A000040, A063826, A157426, A157428, A174344, A268038, A325604, A325606, A331400, A332583.
%K A332582 nonn
%O A332582 1,1
%A A332582 _Scott R. Shannon_, Feb 17 2020