Ulam spiral (for primes)

From Rosetta Code
Revision as of 05:36, 14 January 2015 by rosettacode>Gerard Schildberger (added a new (draft) task.)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Ulam spiral (for primes) is a draft programming task. It is not yet considered ready to be promoted as a complete task, for reasons that should be found in its talk page.

A   Ulam spiral   (of primes numbers)   is a method of visualizing prime numbers when expressed in a (normally counter-clockwise) outward spiral (usually starting at   1),   constructed on a square grid, starting at the "center".

A Ulam spiral is also known as a   prime spiral.

The first grid (green) is shown with all numbers (primes and non-primes) shown, starting at   1.   In an Ulam spiral of primes, only the primes are shown (usually indicated by some glyph such as a dot),   and all non-primes as shown as a blank   (or some other whitespace).   Of course, the grid and border are not to be displayed   (but they are displayed here when using these Wiki HTML tables).

Normally, the spiral starts in the "center", and the 2nd number is to the viewer's right and the number spiral starts from there in a counter-clockwise direction.   There are other geometric shapes that are used as well, including clock-wise spirals.   Also, some spirals (for the 2nd number) is viewed upwards from the 1st number instead of to the right, but that is just a matter of orientation.

Sometimes, the starting number can be specified to show more visual striking patterns (of prime densities).


65 64 63 62 61 60 59 58 57
66 37 36 35 34 33 32 31 56
67 38 17 16 15 14 13 30 55
68 39 18 5 4 3 12 29 54
69 40 19 6 1 2 11 28 53
70 41 20 7 8 9 10 27 52
71 42 21 22 23 24 25 26 51
72 43 44 45 46 47 48 49 50
73 74 75 76 77 78 79 80 81


[A larger than necessary grid (numbers wise) is shown here to show the pattern of numbers on the diagonals   (which may be used by the method to orientate the direction of spiral-construction algorithm within the example computer programs)].


Then, to show the Ulam prime spiral, a character (or glyph) is shown instead of each prime number, and a blank for all non-prime numbers.   In the orange grid below, the prime numbers are left intact to see what numbers are to be changed to the character for viewing.


61 59
37 31
67 17 13
5 3 29
19 2 11 53
41 7
71 23
43 47
73 79


Task

For any sized   N x N   grid, construct and show an Ulam spiral (counter-clockwise) of primes starting at some specified initial number   (the default would be   1),   with some specifiable character to be used to indicate primes, and blanks for all non-primes.

You should demonstrate the generator by showing at Ulam prime spiral large enough to (almost) fill your terminal screen.

Also see



REXX

counter-clockwise

<lang rexx>/*REXX pgm shows cntr-clockwise Ulam spiral of primes in a square matrix*/ parse arg size init char . /*get the matrix size from the CL*/ if size== | size==',' then size=79 /*No size? Then use default of 79*/ if init== | init==',' then init= 1 /*No init? Then use default of 1 */ if char== then char='█' /*No char? Then use default of █ */ tot=size**2; offset=init-1 /*numbers in spiral; start offset*/ uR.=0; bR.=0 /*the upper/bottom right corners.*/

     do od=1 by 2 to tot; _=od**2+1+offset; uR._=1; _=_ + od; bR._=1; end

bL.=0; uL.=0 /*the bottom/upper left corners. */

     do ev=2 by 2 to tot; _=ev**2+1+offset; bL._=1; _=_ + ev; uL._=1; end

$.= bigP=0; #p=0; app=1; inc=0; r=1; $=0; minR=1; maxR=1; $=0;  !.= /*──────────────────────────────────────────────construct the spiral #s.*/

 do i=init  for tot;  r=r+inc;  minR=min(minR,r);   maxR=max(maxR,r)
 x=isPrime(i);  if x  then bigP=max(bigP,i);  #p=#p+x  /*bigP, #primes.*/
 if app  then $.r=$.r ||  x                            /*append  token.*/
         else $.r= x  || $.r                           /*prepend token.*/
 if uR.i  then do;  app=1;  inc=+1;  iterate;  end     /*advance  ↓    */
 if bL.i  then do;  app=0;  inc=-1;  iterate;  end     /*   "     ↑    */
 if bR.i  then do;  app=0;  inc= 0;  iterate;  end     /*   "     ►    */
 if uL.i  then do;  app=1;  inc= 0;  iterate;  end     /*   "     ◄    */
 end   /*i*/
 do j=minR  to maxR  by 2;    jp=j+1;    $=$+1         /*fold two lines*/
   do k=1  for  length($.j);  top=substr($.j,k,1)      /*the   1st line*/
                              bot=word(substr($.jp,k,1) 0,1) /*2nd line*/
   if top  then if bot  then !.$=!.$'█'                /*has top & bot.*/
                        else !.$=!.$'▀'                /*has top,¬ bot.*/
           else if bot  then !.$=!.$'▄'                /*¬ top, has bot*/
                        else !.$=!.$' '                /*¬ top,   ¬ bot.*/
    end   /*k*/
  end     /*j*/                        /* [↓]  show prime# spiral matrix*/
                                   do m=1  for $;   say !.m;   end  /*m*/

say; say init 'is the starting point,' ,

     tot  'numbers used,'   #p   "primes found, largest prime:"   bigP

exit /*stick a fork in it, we're done.*/ /*───────────────────────────────────ISPRIME subroutine──────────────────────────────*/ isPrime: procedure; parse arg x; if x<2 then return 0 if wordpos(x,'2 3 5 7')\==0 then return 1 if x//2==0 then return 0; if x//3==0 then return 0

  do j=5 by 6 until j*j>x; if x//j==0 then return 0; if x//(j+2)==0 then return 0; end

return 1</lang> output   when the default inputs are used:

      ▀     ▀     ▀          ▄  ▀  ▄ ▄▀  ▄▀     ▀       ▀    ▄     ▄      ▀  ▄▀
 ▄▀     ▀▄       ▄   ▄        ▀    ▄▀ ▀  ▄▀     ▀           ▀ ▀   ▀  ▄  ▀  ▄
▀ ▀      ▄      ▀          ▄▀    ▄▀    ▄    ▀  ▄               ▄     ▄    ▀
▀▄ ▄▀ ▀    ▄ ▄▀         ▀▄▀    ▄    ▀          ▄     ▄ ▄          ▀         ▀
  ▀    ▄         ▄  ▀      ▄ ▄▀ ▀      ▄          ▀▄ ▄  ▀   ▀  ▄     ▄  ▀  ▄ ▄
        ▀  ▄  ▀ ▀          ▄▀▄  ▀      ▄    ▀ ▀     ▀   ▀  ▄  ▀  ▄  ▀▄
    ▀ ▀     ▀      ▄▀    ▄▀  ▄ ▄▀  ▄     ▄▀    ▄  ▀    ▄   ▄ ▄     ▄  ▀▄ ▄  ▀▄
 ▄ ▄    ▀▄   ▄         ▄   ▄     ▄    ▀▄  ▀    ▄▀  ▄ ▄  ▀         ▀     ▀▄ ▄
▀    ▄  ▀ ▀   ▀     ▀▄▀▄          ▀      ▄  ▀ ▀▄  ▀ ▀▄              ▀▄     ▄
     ▄    ▀  ▄ ▄   ▄   ▄▀     ▀     ▀▄   ▄▀      ▄▀  ▄      ▀ ▀ ▀▄▀ ▀  ▄  ▀ ▀▄
       ▄ ▄   ▄ ▄     ▄    ▀▄ ▄  ▀  ▄▀ ▀▄ ▄▀             ▀  ▄▀▄ ▄     ▄ ▄      ▀
    ▀▄▀     ▀       ▀     ▀▄▀▄     ▄   ▄          ▀▄    ▀▄           ▄▀   ▀
 ▄       ▄         ▄ ▄               ▄▀  ▄▀ ▀   ▀▄   ▄ ▄      ▀ ▀ ▀▄  ▀ ▀   ▀
  ▀▄    ▀    ▄     ▄▀▄   ▄▀▄  ▀  ▄ ▄     ▄▀ ▀  ▄  ▀        ▄           ▄▀     ▀
▀ ▀  ▄          ▀▄  ▀ ▀▄     ▄   ▄▀      ▄    ▀▄  ▀     ▀ ▀    ▄▀          ▄
 ▄   ▄   ▄      ▀▄▀▄ ▄ ▄▀   ▀  ▄     ▄▀   ▀ ▀  ▄▀▄▀ ▀▄     ▄ ▄     ▄  ▀
  ▀                       ▀     ▀   ▀ ▀▄ ▄     ▄   ▄  ▀▄ ▄  ▀▄ ▄ ▄▀  ▄ ▄     ▄
    ▀     ▀ ▀ ▀     ▀   ▀   ▀   ▀ ▀   ▀▄ ▄   ▄▀   ▀ ▀         ▀▄          ▀▄
▀▄  ▀▄ ▄  ▀▄ ▄  ▀ ▀▄  ▀▄ ▄ ▄ ▄▀▄ ▄▀▄▀▄   ▄▀ ▀ ▀  ▄  ▀ ▀ ▀  ▄ ▄         ▄▀ ▀
       ▄ ▄   ▄     ▄             ▄   ▄▀ █▄▀▄ ▄ ▄   ▄ ▄▀▄     ▄    ▀  ▄ ▄▀▄ ▄
    ▀ ▀ ▀  ▄    ▀ ▀       ▀       ▀▄▀ ▀▄
     ▄ ▄   ▄   ▄▀ ▀  ▄  ▀  ▄▀ ▀▄  ▀▄▀   ▀▄  ▀ ▀▄ ▄▀  ▄▀ ▀   ▀▄  ▀ ▀▄     ▄▀  ▄
 ▄▀▄    ▀▄    ▀    ▄ ▄         ▄ ▄  ▀  ▄   ▄   ▄▀      ▄ ▄  ▀    ▄      ▀▄   ▄
▀ ▀ ▀ ▀             ▀ ▀▄    ▀▄  ▀  ▄   ▄ ▄  ▀       ▀     ▀         ▀     ▀
▀  ▄   ▄    ▀▄ ▄       ▄ ▄ ▄ ▄    ▀ ▀  ▄▀▄    ▀▄  ▀  ▄ ▄▀  ▄▀▄▀ ▀▄       ▄▀  ▄
 ▄ ▄     ▄     ▄     ▄   ▄▀▄  ▀  ▄     ▄  ▀▄▀▄           ▄     ▄   ▄ ▄ ▄     ▄
  ▀  ▄  ▀ ▀ ▀ ▀ ▀▄    ▀ ▀       ▀▄ ▄   ▄ ▄▀       ▀▄    ▀▄            ▀   ▀
   ▄▀      ▄      ▀▄       ▄ ▄▀   ▀▄    ▀     ▀      ▄  ▀ ▀     ▀  ▄    ▀▄  ▀▄▀
  ▀          ▄▀▄    ▀   ▀       ▀           ▀   ▀▄    ▀▄   ▄     ▄▀     ▀  ▄
▀    ▄▀   ▀ ▀    ▄  ▀   ▀ ▀   ▀    ▄▀    ▄   ▄ ▄▀             ▀▄    ▀▄▀     ▀
    ▀      ▄ ▄ ▄▀     ▀▄     ▄   ▄▀▄   ▄  ▀    ▄     ▄    ▀   ▀     ▀        ▄
 ▄     ▄      ▀    ▄            ▀▄     ▄   ▄ ▄     ▄   ▄▀   ▀▄               ▄
           ▄▀ ▀     ▀  ▄         ▄        ▀  ▄ ▄     ▄▀ ▀▄ ▄        ▀ ▀    ▄
▀▄     ▄ ▄  ▀        ▄     ▄       ▄   ▄▀ ▀    ▄    ▀       ▀   ▀   ▀   ▀
       ▄           ▄▀▄   ▄          ▀  ▄    ▀▄  ▀▄▀   ▀ ▀▄         ▄    ▀▄    ▀
    ▀▄▀ ▀   ▀     ▀ ▀  ▄▀     ▀ ▀           ▀  ▄▀        ▄     ▄ ▄  ▀
 ▄  ▀ ▀        ▄        ▀     ▀  ▄▀▄    ▀▄   ▄▀                ▄▀ ▀    ▄    ▀
 ▄    ▀▄           ▄▀    ▄▀▄    ▀   ▀     ▀▄▀    ▄    ▀▄▀            ▄  ▀
     ▄  ▀▄    ▀▄ ▄  ▀   ▀  ▄ ▄  ▀         ▀  ▄     ▄                   ▄  ▀▄
▀         ▀                       ▀ ▀   ▀       ▀     ▀   ▀       ▀

1 is the starting point, 6241 numbers used, 811 primes found, largest prime: 6229

output   when the following input is used: &nbsp ,   41

    ▀▄     ▄▀    ▄      ▀  ▄      ▀▄▀  ▄      ▀     ▀     ▀          ▄  ▀  ▄ ▄▀
            ▀   ▀ ▀▄           ▄    ▀  ▄▀ ▀     ▀▄       ▄   ▄        ▀    ▄▀
 ▄▀▄   ▄▀   ▀▄▀    ▄ ▄    ▀▄   ▄ ▄  ▀     ▀      ▄      ▀          ▄▀    ▄▀ ▀▄▀
▀ ▀ ▀ ▀    ▄▀  ▄ ▄            ▀  ▄      ▀    ▄▀    ▄ ▄▀         ▀▄▀    ▄
▀  ▄   ▄    ▀▄  ▀  ▄       ▄  ▀  ▄   ▄  ▀ ▀▄  ▀          ▄  ▀      ▄ ▄▀    ▄▀
 ▄ ▄     ▄         ▄ ▄  ▀▄▀               ▀ ▀      ▄  ▀ ▀          ▄▀ ▀ ▀▄    ▀
  ▀  ▄  ▀ ▀ ▀   ▀▄         ▄ ▄▀        ▄  ▀  ▄ ▄   ▄▀      ▄▀    ▄▀▄
   ▄▀      ▄    ▀  ▄ ▄  ▀  ▄      ▀              ▄ ▄▀          ▄    ▀     ▀ ▀
  ▀          ▄▀▄    ▀▄        ▀ ▀   ▀     ▀▄▀▄              ▀▄▀  ▄
▀    ▄▀   ▀ ▀    ▄    ▀▄         ▄▀ ▀  ▄▀▄    ▀▄   ▄ ▄     ▄ ▄ ▄ ▄▀  ▄   ▄    ▀
    ▀      ▄ ▄ ▄▀     ▀ ▀      ▄  ▀  ▄ ▄      ▀    ▄▀ ▀▄ ▄▀
 ▄     ▄      ▀     ▀    ▄▀▄    ▀    ▄▀▄        ▀▄     ▄▀  ▄▀    ▄ ▄   ▄
           ▄▀ ▀   ▀ ▀   ▀  ▄▀▄      ▀  ▄ ▄    ▀      ▄▀▄ ▄     ▄             ▄
▀▄     ▄ ▄  ▀  ▄ ▄    ▀▄ ▄ ▄   ▄  ▀  ▄    ▀▄ ▄     ▄▀               ▀       ▀
       ▄            ▀    ▄▀▄  ▀▄▀    ▄ ▄    ▀    ▄▀   ▀   ▀ ▀ ▀ ▀▄▀ ▀ ▀▄    ▀
    ▀▄▀ ▀     ▀         ▀    ▄     ▄▀     ▀  ▄▀▄▀▄       ▄     ▄     ▄ ▄     ▄
 ▄  ▀ ▀          ▄            ▀     ▀▄ ▄▀ ▀  ▄▀   ▀▄    ▀▄      ▀    ▄      ▀
 ▄      ▀    ▄     ▄▀           ▀   ▀▄▀▄   ▄▀  ▄    ▀▄ ▄▀ ▀ ▀    ▄  ▀ ▀  ▄
    ▀      ▄     ▄▀     ▀ ▀  ▄  ▀  ▄    ▀▄▀            ▄   ▄ ▄    ▀        ▄  ▀
▀  ▄     ▄▀     ▀▄    ▀  ▄    ▀  ▄ ▄▀▄ ▄▀   ▀▄           ▄▀   ▀▄▀   ▀ ▀     ▀
 ▄      ▀▄     ▄   ▄       ▄   ▄ ▄   ▄▀   ▀    ▄▀▄▀ ▀     ▀▄▀ ▀         ▀▄   ▄▀
  ▀  ▄  ▀  ▄     ▄    ▀   ▀       ▀▄▀     ▀  ▄ ▄   ▄   ▄ ▄   ▄ ▄ ▄ ▄ ▄     ▄
 ▄       ▄   ▄    ▀▄ ▄ ▄    ▀▄▀▄ ▄▀▄    ▀     ▀   ▀ ▀    ▄▀   ▀▄    ▀     ▀
       ▄▀      ▄   ▄▀          ▄▀  ▄  ▀     ▀   ▀      ▄      ▀ ▀▄          ▀
▀ ▀                   ▀▄  ▀  ▄▀▄   ▄▀       ▀  ▄▀  ▄ ▄▀    ▄▀▄   ▄ ▄ ▄  ▀  ▄ ▄
 ▄ ▄▀ ▀    ▄   ▄ ▄   ▄ ▄▀  ▄▀▄   ▄    ▀▄    ▀▄ ▄  ▀                 ▀▄
 ▄      ▀     ▀▄         ▄▀  ▄ ▄  ▀▄    ▀   ▀    ▄  ▀▄▀    ▄       ▄  ▀▄ ▄  ▀▄
  ▀     ▀ ▀▄▀         ▀▄▀    ▄▀    ▄▀      ▄▀    ▄▀    ▄          ▀     ▀▄ ▄
   ▄▀ ▀     ▀▄   ▄   ▄▀     ▀▄          ▀      ▄  ▀      ▄          ▀▄     ▄
  ▀▄     ▄   ▄ ▄    ▀       ▀  ▄   ▄ ▄  ▀     ▀▄  ▀     ▀  ▄▀ ▀ ▀▄▀ ▀  ▄  ▀ ▀▄
     ▄▀           ▀    ▄ ▄      ▀  ▄  ▀   ▀ ▀   ▀▄▀        ▄▀  ▄     ▄ ▄      ▀
 ▄  ▀▄    ▀▄   ▄▀   ▀▄    ▀      ▄▀    ▄     ▄    ▀ ▀   ▀  ▄   ▄     ▄▀   ▀
 ▄       ▄   ▄▀ ▀▄ ▄            ▀  ▄    ▀   ▀    ▄   ▄  ▀  ▄      ▀▄  ▀ ▀   ▀
  ▀ ▀ ▀ ▀ ▀ ▀       ▀   ▀    ▄ ▄   ▄ ▄▀   ▀      ▄▀           ▀        ▄▀     ▀
     ▄   ▄▀   ▀ ▀▄         ▄       ▄  ▀  ▄    ▀▄          ▀     ▀    ▄     ▄
       ▄▀        ▄     ▄ ▄  ▀      ▄ ▄         ▄ ▄▀        ▄  ▀ ▀▄ ▄▀
▀   ▀▄▀                ▄▀ ▀    ▄    ▀             ▀    ▄▀  ▄▀▄▀  ▄▀    ▄ ▄   ▄
▀  ▄▀    ▄    ▀▄▀            ▄  ▀      ▄    ▀       ▀▄   ▄            ▀   ▀
  ▀  ▄     ▄                   ▄  ▀▄           ▄  ▀ ▀     ▀  ▄▀ ▀   ▀ ▀
▀       ▀     ▀   ▀       ▀                 ▀         ▀     ▀     ▀ ▀     ▀

41 is the starting point, 6241 numbers used, 805 primes found, largest prime: 6277

clockwise

This REXX version is presented here to show the difference between a clockwise and a counter-clockwise Ulam (prime) spiral. <lang rexx>/*REXX pgm shows a clockwise Ulam spiral of primes in a square matrix. */ parse arg size init char . /*get the matrix size from the CL*/ if size== | size==',' then size=79 /*No size? Then use default of 79*/ if init== | init==',' then init= 1 /*No init? Then use default of 1 */ if char== then char='█' /*No char? Then use default of █ */ tot=size**2; offset=init-1 /*numbers in spiral; start offset*/ uR.=0; bR.=0 /*the upper/bottom right corners.*/

     do od=1 by 2 to tot; _=od**2+1+offset; uR._=1; _=_ + od; bR._=1; end

bL.=0; uL.=0 /*the bottom/upper left corners. */

     do ev=2 by 2 to tot; _=ev**2+1+offset; bL._=1; _=_ + ev; uL._=1; end

$.= bigP=0; #p=0; app=1; inc=0; r=1; $=0; minR=1; maxR=1; $=0;  !.= /*──────────────────────────────────────────────construct the spiral #s.*/

 do i=init  for tot;  r=r+inc;  minR=min(minR,r);   maxR=max(maxR,r)
 x=isPrime(i);  if x  then bigP=max(bigP,i);  #p=#p+x  /*bigP, #primes.*/
 if app  then $.r=$.r ||  x                            /*append  token.*/
         else $.r= x  || $.r                           /*prepend token.*/
 if uR.i  then do;  app=1;  inc=+1;  iterate;  end     /*advance  ↓    */
 if bL.i  then do;  app=0;  inc=-1;  iterate;  end     /*   "     ↑    */
 if bR.i  then do;  app=0;  inc= 0;  iterate;  end     /*   "     ►    */
 if uL.i  then do;  app=1;  inc= 0;  iterate;  end     /*   "     ◄    */
 end   /*i*/
 do j=minR  to maxR  by 2;    jp=j+1;    $=$+1         /*fold two lines*/
   do k=1  for  length($.j);  top=substr($.j,k,1)      /*the   1st line*/
                              bot=word(substr($.jp,k,1) 0,1) /*2nd line*/
   if top  then if bot  then !.$=!.$'█'                /*has top & bot.*/
                        else !.$=!.$'▀'                /*has top,¬ bot.*/
           else if bot  then !.$=!.$'▄'                /*¬ top, has bot*/
                        else !.$=!.$' '                /*¬ top,   ¬ bot*/
    end   /*k*/
  end     /*j*/                        /* [↓]  show prime# spiral matrix*/
                                   do m=1  for $;   say !.m;   end  /*m*/

say; say init 'is the starting point,' ,

     tot  'numbers used,'   #p   "primes found, largest prime:"   bigP

exit /*stick a fork in it, we're done.*/ /*───────────────────────────────────ISPRIME subroutine──────────────────────────────*/ isPrime: procedure; parse arg x; if x<2 then return 0 if wordpos(x,'2 3 5 7')\==0 then return 1 if x//2==0 then return 0; if x//3==0 then return 0

  do j=5 by 6 until j*j>x; if x//j==0 then return 0; if x//(j+2)==0 then return 0; end

return 1</lang> output   when using the default input:

▀    ▄   ▄▀    ▄ ▄         ▄ ▄    ▀ ▀   ▀    ▄  ▀  ▄  ▀   ▀       ▀    ▄   ▄
 ▄     ▄▀     ▀    ▄▀   ▀▄ ▄    ▀         ▀▄     ▄     ▄             ▄    ▀
 ▄    ▀        ▄    ▀     ▀     ▀▄ ▄▀    ▄▀ ▀▄        ▀ ▀      ▄       ▄▀
    ▀▄▀                ▄▀     ▀   ▀     ▀     ▀▄         ▄     ▄▀▄▀         ▀
    ▀ ▀▄▀   ▀     ▀▄▀▄  ▀▄    ▀ ▀      ▄    ▀▄  ▀▄       ▄         ▄▀    ▄
 ▄     ▄ ▄          ▀▄     ▄       ▄▀  ▄    ▀  ▄▀ ▀   ▀ ▀               ▀     ▀
▀          ▄▀          ▄         ▄      ▀ ▀  ▄ ▄    ▀▄   ▄ ▄▀   ▀   ▀   ▀  ▄
 ▄     ▄    ▀ ▀    ▄▀            ▄     ▄  ▀▄ ▄     ▄  ▀▄▀    ▄      ▀ ▀      ▄
           ▄ ▄▀▄       ▄     ▄  ▀▄ ▄   ▄       ▄     ▄  ▀   ▀                ▄
    ▀▄          ▀▄    ▀           ▀▄     ▄▀  ▄ ▄          ▀   ▀▄    ▀▄
▀     ▀   ▀ ▀▄ ▄    ▀   ▀ ▀   ▀     ▀           ▀▄     ▄   ▄  ▀  ▄  ▀ ▀    ▄▀
  ▀▄       ▄  ▀    ▄▀   ▀  ▄ ▄  ▀  ▄        ▀   ▀    ▄▀           ▀▄    ▀▄   ▄
    ▀▄           ▄▀           ▀  ▄▀▄   ▄▀▄    ▀    ▄    ▀▄▀     ▀       ▀   ▀ ▀
 ▄▀▄    ▀▄▀ ▀ ▀▄▀    ▄▀ ▀▄ ▄    ▀▄     ▄  ▀▄ ▄    ▀     ▀▄     ▄   ▄ ▄▀▄  ▀  ▄
   ▄   ▄     ▄ ▄       ▄ ▄▀▄ ▄▀        ▄ ▄▀ ▀  ▄     ▄ ▄   ▄ ▄   ▄       ▄   ▄
▀           ▀          ▄     ▄    ▀▄▀  ▄▀▄    ▀   ▀     ▀   ▀ ▀ ▀         ▀
▀▄▀▄▀ ▀  ▄         ▄▀▄▀     ▀  ▄▀▄     ▄   ▄▀  ▄    ▀  ▄ ▄▀      ▄  ▀    ▄▀  ▄
  ▀  ▄ ▄▀  ▄  ▀▄     ▄     ▄   ▄   ▄▀    ▄     ▄▀▄   ▄      ▀▄     ▄    ▀▄   ▄
           ▄    ▀ ▀     ▀   ▀ ▀   ▀▄▀  ▄▀   ▀ ▀   ▀   ▀ ▀   ▀   ▀ ▀       ▀
    ▀ ▀▄▀▄   ▄  ▀ ▀▄      ▀      ▄▀ ▀▄▀ ▄▄ ▄ ▄ ▄   ▄ ▄ ▄     ▄       ▄ ▄ ▄ ▄
 ▄   ▄ ▄   ▄ ▄     ▄   ▄ ▄ ▄ ▄ ▄ ▄ ▄ ▄▀ ▀▄▀      ▄    ▀    ▄ ▄    ▀    ▄▀
▀   ▀     ▀     ▀ ▀   ▀       ▀   ▀ ▀  ▄ ▄▀ ▀▄▀     ▀ ▀ ▀      ▄        ▀ ▀▄
    ▀     ▀ ▀ ▀     ▀   ▀   ▀   ▀ ▀   ▀▄ ▄    ▀▄  ▀▄▀  ▄ ▄   ▄▀▄ ▄   ▄ ▄  ▀  ▄
 ▄▀  ▄   ▄       ▄ ▄ ▄ ▄  ▀    ▄▀   ▀▄▀        ▄ ▄   ▄▀    ▄▀▄    ▀▄
     ▄          ▀▄▀    ▄▀   ▀▄   ▄    ▀  ▄▀ ▀  ▄▀ ▀ ▀          ▄      ▀    ▄
▀ ▀▄         ▄  ▀  ▄▀▄▀  ▄ ▄     ▄▀▄     ▄    ▀▄  ▀     ▀ ▀▄    ▀      ▄
 ▄▀     ▀▄         ▄▀▄    ▀   ▀      ▄   ▄▀ ▀    ▄▀  ▄ ▄           ▄    ▀     ▀
     ▄                     ▄ ▄     ▄  ▀▄  ▀ ▀   ▀  ▄     ▄    ▀ ▀ ▀  ▄▀ ▀   ▀
    ▀ ▀▄ ▄  ▀▄ ▄    ▀▄    ▀▄▀▄     ▄   ▄ ▄        ▀     ▀  ▄ ▄ ▄     ▄▀▄  ▀
     ▄       ▄ ▄   ▄   ▄  ▀     ▀   ▀▄▀  ▄▀      ▄   ▄  ▀   ▀    ▄     ▄     ▄▀
     ▄    ▀          ▄ ▄▀     ▀     ▀    ▄▀    ▄  ▀  ▄      ▀ ▀ ▀ ▀ ▀▄    ▀▄▀
▀▄ ▄    ▀▄▀  ▄▀     ▀ ▀▄   ▄     ▄▀    ▄    ▀ ▀▄  ▀▄▀▄              ▀    ▄ ▄
        ▀          ▄     ▄   ▄ ▄   ▄  ▀  ▄▀    ▄▀      ▄▀  ▄ ▄    ▀▄   ▄▀▄   ▄
    ▀ ▀    ▄▀       ▀     ▀▄ ▄  ▀      ▄  ▀       ▀        ▄     ▄   ▄▀     ▀
       ▄▀     ▀ ▀▄         ▄▀▄  ▀      ▄    ▀ ▀    ▄▀▄  ▀     ▀▄    ▀▄     ▄ ▄
 ▄▀▄       ▄ ▄      ▀    ▄    ▀▄▀              ▄  ▀  ▄ ▄▀   ▀           ▀
▀   ▀ ▀  ▄    ▀         ▀ ▀▄     ▄  ▀  ▄       ▄               ▄  ▀  ▄      ▀
▀▄▀      ▄      ▀▄   ▄      ▀     ▀▄     ▄  ▀                        ▄    ▀▄
  ▀     ▀                    ▄▀    ▄▀▄▀  ▄▀     ▀           ▀▄▀   ▀▄    ▀    ▄
      ▀     ▀     ▀             ▀     ▀   ▀     ▀       ▀                 ▀   ▀

1 is the starting point, 6241 numbers used, 811 primes found, largest prime: 6229