Ludic numbers   are related to prime numbers as they are generated by a sieve quite like the Sieve of Eratosthenes is used to generate prime numbers.

The first ludic number is   1.

To generate succeeding ludic numbers create an array of increasing integers starting from   2.

2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 ...
(Loop)

 Take the first member of the resultant array as the next ludic number   2.
 Remove every   2nd   indexed item from the array (including the first).
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 ...
 (Unrolling a few loops...)
 Take the first member of the resultant array as the next ludic number   3.
 Remove every   3rd   indexed item from the array (including the first).
3 5 7 9 11 13 15 17 19 21 23 25 27 29 31 33 35 37 39 41 43 45 47 49 51 ...
 Take the first member of the resultant array as the next ludic number   5.
 Remove every   5th   indexed item from the array (including the first).
5 7 11 13 17 19 23 25 29 31 35 37 41 43 47 49 53 55 59 61 65 67 71 73 77 ...
 Take the first member of the resultant array as the next ludic number   7.
 Remove every   7th   indexed item from the array (including the first).
7 11 13 17 23 25 29 31 37 41 43 47 53 55 59 61 67 71 73 77 83 85 89 91 97 ...
  ... 
 Take the first member of the current array as the next ludic number   L.
 Remove every   Lth   indexed item from the array (including the first).
  ... 


Task

 Generate and show here the first 25 ludic numbers.
 How many ludic numbers are there less than or equal to 1000?
 Show the 2000..2005th ludic numbers.


Stretch goal

Show all triplets of ludic numbers < 250.

 A triplet is any three numbers     



x
,


{\displaystyle x,}

   



x
+
2
,


{\displaystyle x+2,}

   



x
+
6


{\displaystyle x+6}

      where all three numbers are also ludic numbers. 


/*REXX program gens/shows (a range of)  ludic numbers,  or a count when a range is used.*/
parse arg N count bot top triples .              /*obtain optional arguments from the CL*/
if       N=='' |       N=="," then       N=   25 /*Not specified?  Then use the default.*/
if   count=='' |   count=="," then   count= 1000 /* "      "         "   "   "     "    */
if     bot=='' |     bot=="," then     bot= 2000 /* "      "         "   "   "     "    */
if     top=='' |     top=="," then     top= 2005 /* "      "         "   "   "     "    */
if triples=='' | triples=="," then triples=  249 /* "      "         "   "   "     "    */
#= 0                                             /*the number of ludic numbers (so far).*/
$= ludic( max(N, count, bot, top, triples) )                /*generate enough ludic nums*/
say 'The first '   N   " ludic numbers: "   subword($,1,25) /*display 1st  N  ludic nums*/
               do j=1  until word($, j) > count             /*search up to a specific #.*/
               end   /*j*/
say
say "There are "          j - 1           ' ludic numbers that are  ≤ '            count
say
say "The "  bot  '───►'     top     ' (inclusive)  ludic numbers are: '    subword($, bot)
@=                                               /*list of ludic triples found (so far).*/
     do j=1  for words($)
     _= word($, j)                               /*it is known that ludic   _   exists. */
     if _>=triples  then leave                   /*only process up to a specific number.*/
     if wordpos(_+2, $)==0 | wordpos(_+6, $)==0  then iterate    /*Not triple?  Skip it.*/
     #= # + 1                                    /*bump the triple counter.             */
     @= @ '◄'_  _+2  _+6"► "                     /*append the newly found triple ──►  @ */
     end   /*j*/
say
if @==''  then  say  'From 1──►'triples", no triples found."
          else  say  'From 1──►'triples", "     #     ' triples found:'      @
exit                                             /*stick a fork in it,  we're all done. */
/*──────────────────────────────────────────────────────────────────────────────────────*/
ludic: procedure; parse arg m,,@;    $= 1 2      /*$≡ludic numbers superset;  @≡sequence*/
           do j=3  by 2  to  m*15;   @= @ j      /*construct an initial list of numbers.*/
           end   /*j*/
       @= @' ';                    n= words(@)   /*append a blank to the number sequence*/
           do while n\==0;         f= word(@, 1) /*examine the first word in the @ list.*/
           $= $ f                                /*add the word to the  $  list.        */
              do d=1  by f  while d<=n;   n= n-1 /*use 1st number, elide all occurrences*/
              @= changestr(' 'word(@, d)" ",  @,  ' . ')     /*cross─out a number in  @ */
              end   /*d*/                        /* [↑]  done eliding the "1st" number. */
           @= translate(@, , .)                  /*change dots to blanks; count numbers.*/
           end      /*while*/                    /* [↑]  done eliding ludic numbers.    */
       return subword($, 1, m)                   /*return a  range  of  ludic  numbers. */