Cyclops numbers: Difference between revisions

From Rosetta Code
Content added Content deleted
m (→‎{{header|Pascal}}: forgot </pre>)
m (→‎{{header|Pascal}}: added link to factor for 1 billionth cyclops number)
Line 911: Line 911:
Execution time: 2.936 seconds.</pre>
Execution time: 2.936 seconds.</pre>
=={{header|Pascal}}==
=={{header|Pascal}}==
simple trial division for isprime is very slow.
simple trial division for isprime is very slow.<BR>
Try to find one billionth like [[Cyclops_numbers#Factor]]
<lang pascal>program cyclops;
<lang pascal>program cyclops;
{$IFDEF FPC}
{$IFDEF FPC}
Line 1,234: Line 1,235:
114808411 at index 67
114808411 at index 67


1000000000.th = 35296098111 // takes 4.6 sec
1000000000.th = 35296098111 // takes ~4.6 sec


Real time: 5.378 s CPU share: 98.10 %
Real time: 5.378 s CPU share: 98.10 %

Revision as of 09:32, 30 June 2021

Cyclops numbers 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 cyclops number is a number with an odd number of digits that has a zero in the center, but nowhere else. They are named so in tribute to the one eyed giants Cyclops from Greek mythology.

Cyclops numbers can be found in any base. This task strictly is looking for cyclops numbers in base 10.

There are many different classifications of cyclops numbers with minor differences in characteristics. In an effort to head off a whole series of tasks with tiny variations, we will cover several variants here.


Task
  • Find and display here on this page the first 50 cyclops numbers in base 10 (all of the sub tasks are restricted to base 10).
  • Find and display here on this page the first 50 prime cyclops numbers. (cyclops numbers that are prime.)
  • Find and display here on this page the first 50 blind prime cyclops numbers. (prime cyclops numbers that remain prime when "blinded"; the zero is removed from the center.)
  • Find and display here on this page the first 50 palindromic prime cyclops numbers. (prime cyclops numbers that are palindromes.)


Stretch
  • Find and display the first cyclops number greater than ten million (10,000,000) and the index (place) in the series where it is found.
  • Find and display the first prime cyclops number greater than ten million (10,000,000) and the index (place) in the series where it is found.
  • Find and display the first blind prime cyclops number greater than ten million (10,000,000) and the index (place) in the series where it is found.
  • Find and display the first palindromic prime cyclops number greater than ten million (10,000,000) and the index (place) in the series where it is found.

(Note: there are no cyclops numbers between ten million and one hundred million, they need to have an odd number of digits)


See also



ALGOL 68

Generates the sequence. <lang algol68>BEGIN # show cyclops numbers - numbers with a 0 in the middle and no other 0 digits #

   INT max prime = 100 000;
   # sieve the primes to max prime #
   [ 1 : max prime ]BOOL prime;
   prime[ 1 ] := FALSE; prime[ 2 ] := TRUE;
   FOR i FROM 3 BY 2 TO UPB prime DO prime[ i ] := TRUE  OD;
   FOR i FROM 4 BY 2 TO UPB prime DO prime[ i ] := FALSE OD;
   FOR i FROM 3 BY 2 TO ENTIER sqrt( max prime ) DO
       IF prime[ i ] THEN FOR s FROM i * i BY i + i TO UPB prime DO prime[ s ] := FALSE OD FI
   OD;
   # returns TRUE if c is prime, FALSE otherwise #
   PROC have a prime = ( INT c )BOOL:
        IF   c < 2 THEN FALSE
        ELIF c < max prime
        THEN prime[ c ]
        ELSE # the cyclops number is too large for the sieve, use trial division #
           BOOL possibly prime := ODD c;
           FOR d FROM 3 BY 2 WHILE d * d <= c AND possibly prime DO possibly prime := c MOD d /= 0 OD;
           possibly prime
        FI # have a prime # ;
   # arrays of the cyclops numbers we must show #
   [ 1 : 50 ]INT first cyclops;                   INT cyclops count                   := 0;
   [ 1 : 50 ]INT first prime cyclops;             INT prime cyclops count             := 0;
   [ 1 : 50 ]INT first palindromic prime cyclops; INT palindromic prime cyclops count := 0;
   [ 1 : 50 ]INT first blind prime cyclops;       INT blind prime cyclops count       := 0;
   # notes c is a cyclops number, palindromic indicates whether it is palindromic or not #
   #       bc should be c c with the middle 0 removed #
   # if c is one of the first 50 of various classifications, #
   #    it is stored in the appropriate array #
   PROC have cyclops = ( INT c, BOOL palindromic, INT bc )VOID:
        BEGIN
           cyclops count +:= 1;
           IF cyclops count <= UPB first cyclops THEN first cyclops[ cyclops count ] := c FI;
           IF   prime cyclops count             < UPB first prime cyclops
           OR ( palindromic prime cyclops count < UPB first palindromic prime cyclops AND palindromic )
           OR   blind prime cyclops count       < UPB first blind prime cyclops
           THEN
               IF have a prime( c ) THEN
                   # have a prime cyclops #
                   IF prime cyclops count < UPB first prime cyclops THEN
                      first prime cyclops[ prime cyclops count +:= 1 ] := c
                   FI;
                   IF palindromic prime cyclops count < UPB first palindromic prime cyclops AND palindromic THEN
                      first palindromic prime cyclops[ palindromic prime cyclops count +:= 1 ] := c
                   FI;
                   IF blind prime cyclops count < UPB first blind prime cyclops THEN
                       IF have a prime( bc ) THEN
                           first blind prime cyclops[ blind prime cyclops count +:= 1 ] := c
                       FI
                   FI
               FI
           FI
        END # have cyclops # ;
   # prints a cyclops sequence #
   PROC print cyclops = ( []INT seq, STRING legend, INT elements per line )VOID:
        BEGIN
           print( ( "The first ", whole( ( UPB seq - LWB seq ) + 1, 0 ), " ", legend, ":", newline, "   " ) );
           FOR i FROM LWB seq TO UPB seq DO
               print( ( " ", whole( seq[ i ], -7 ) ) );
               IF i MOD elements per line = 0 THEN print( ( newline, "   " ) ) FI
           OD;
           print( ( newline ) )
        END # print cyclops # ;
   # generate the cyclops numbers #
   # 0 is the first and only cyclops number with less than three digits #
   have cyclops( 0, TRUE, 0 );
   # generate the 3 digit cyclops numbers #
   FOR f TO 9 DO
       FOR b TO 9 DO
           have cyclops( ( f * 100 ) + b
                       , f = b
                       , ( f * 10 ) + b
                       )
       OD
   OD;
   # generate the 5 digit cyclops numbers #
   FOR d1 TO 9 DO
       FOR d2 TO 9 DO
           INT d1200  = ( ( d1 * 10 ) + d2 ) * 100;
           INT d12000 = d1200 * 10;
           FOR d4 TO 9 DO
               INT d40 = d4 * 10;
               FOR d5 TO 9 DO
                   INT d45 = d40 + d5;
                   have cyclops( d12000 + d45
                               , d1 = d5 AND d2 = d4
                               , d1200 + d45
                               )
               OD
           OD
       OD
   OD;
   # generate the 7 digit cyclops numbers #
   FOR d1 TO 9 DO
       FOR d2 TO 9 DO
           FOR d3 TO 9 DO
               INT d123000  = ( ( ( ( d1 * 10 ) + d2 ) * 10 ) + d3 ) * 1000;
               INT d1230000 = d123000 * 10;
               FOR d5 TO 9 DO
                   INT d500 = d5 * 100;
                   FOR d6 TO 9 DO
                       INT d560 = d500 + ( d6 * 10 );
                       FOR d7 TO 9 DO
                           INT d567 = d560 + d7;
                           have cyclops( d1230000 + d567
                                       , d1 = d7 AND d2 = d6 AND d3 = d5
                                       , d123000 + d567
                                       )
                       OD
                   OD
               OD
           OD
       OD
   OD;
   # show parts of the sequence #
   print cyclops( first cyclops,                                     "cyclops numbers", 10 );
   print cyclops( first prime cyclops,                         "prime cyclops numbers", 10 );
   print cyclops( first blind prime cyclops,             "blind prime cyclops numbers", 10 );
   print cyclops( first palindromic prime cyclops, "palindromic prime cyclops numbers", 10 )

END</lang>

Output:
The first 50 cyclops numbers:
          0     101     102     103     104     105     106     107     108     109
        201     202     203     204     205     206     207     208     209     301
        302     303     304     305     306     307     308     309     401     402
        403     404     405     406     407     408     409     501     502     503
        504     505     506     507     508     509     601     602     603     604

The first 50 prime cyclops numbers:
        101     103     107     109     307     401     409     503     509     601
        607     701     709     809     907   11027   11047   11057   11059   11069
      11071   11083   11087   11093   12011   12037   12041   12043   12049   12071
      12073   12097   13033   13037   13043   13049   13063   13093   13099   14011
      14029   14033   14051   14057   14071   14081   14083   14087   15013   15017

The first 50 blind prime cyclops numbers:
        101     103     107     109     307     401     503     509     601     607
        701     709     809     907   11071   11087   11093   12037   12049   12097
      13099   14029   14033   14051   14071   14081   14083   14087   15031   15053
      15083   16057   16063   16067   16069   16097   17021   17033   17041   17047
      17053   17077   18047   18061   18077   18089   19013   19031   19051   19073

The first 50 palindromic prime cyclops numbers:
        101   16061   31013   35053   38083   73037   74047   91019   94049 1120211
    1150511 1160611 1180811 1190911 1250521 1280821 1360631 1390931 1490941 1520251
    1550551 1580851 1630361 1640461 1660661 1670761 1730371 1820281 1880881 1930391
    1970791 3140413 3160613 3260623 3310133 3380833 3460643 3470743 3590953 3670763
    3680863 3970793 7190917 7250527 7310137 7540457 7630367 7690967 7750577 7820287

F#

This task uses Extensible Prime Generator (F#)

Cyclops function

<lang fsharp> // Cyclop numbers. Nigel Galloway: June 25th., 2021 let rec fG n g=seq{yield! g|>Seq.collect(fun i->g|>Seq.map(fun g->n*i+g)); yield! fG(n*10)(fN g)} let cyclops=seq{yield 0; yield! fG 100 [1..9]} let primeCyclops,blindCyclops=cyclops|>Seq.filter isPrime,Seq.zip(fG 100 [1..9])(fG 10 [1..9])|>Seq.filter(fun(n,g)->isPrime n && isPrime g)|>Seq.map fst let palindromicCyclops=let fN g=let rec fN g=[yield g%10; if g>9 then yield! fN(g/10)] in let n=fN g in n=List.rev n in primeCyclops|>Seq.filter fN </lang>

The tasks

First 50 Cyclop numbers

<lang fsharp> cyclops|>Seq.take 50|>Seq.iter(printf "%d "); printfn "" </lang>

Output:
0 101 102 103 104 105 106 107 108 109 201 202 203 204 205 206 207 208 209 301 302 303 304 305 306 307 308 309 401 402 403 404 405 406 407 408 409 501 502 503 504 505 506 507 508 509 601 602 603 604
First 50 prime Cyclop numbers

<lang fsharp> primeCyclops|>Seq.take 50|>Seq.iter(printf "%d "); printfn "" </lang>

Output:
101 103 107 109 307 401 409 503 509 601 607 701 709 809 907 11027 11047 11057 11059 11069 11071 11083 11087 11093 12011 12037 12041 12043 12049 12071 12073 12097 13033 13037 13043 13049 13063 13093 13099 14011 14029 14033 14051 14057 14071 14081 14083 14087 15013 15017
First 50 blind Cyclop numbers

<lang fsharp> blindCyclops|>Seq.take 50|>Seq.iter(printf "%d "); printfn "" </lang>

Output:
101 103 107 109 307 401 503 509 601 607 701 709 809 907 11071 11087 11093 12037 12049 12097 13099 14029 14033 14051 14071 14081 14083 14087 15031 15053 15083 16057 16063 16067 16069 16097 17021 17033 17041 17047 17053 17077 18047 18061 18077 18089 19013 19031 19051 19073
First 50 palindromic prime Cyclop numbers

<lang fsharp> palindromicCyclops|>Seq.take 50|>Seq.iter(printf "%d "); printfn "" </lang>

Output:
101 16061 31013 35053 38083 73037 74047 91019 94049 1120211 1150511 1160611 1180811 1190911 1250521 1280821 1360631 1390931 1490941 1520251 1550551 1580851 1630361 1640461 1660661 1670761 1730371 1820281 1880881 1930391 1970791 3140413 3160613 3260623 3310133 3380833 3460643 3470743 3590953 3670763 3680863 3970793 7190917 7250527 7310137 7540457 7630367 7690967 7750577 7820287
First Cyclop number > 10,000,000

<lang fsharp> let n=cyclops|>Seq.findIndex(fun n->n>10000000) in printfn "First Cyclop number > 10,000,000 is %d at index %d" (Seq.item n (cyclops)) n </lang>

Output:
First Cyclop number > 10,000,000 is 111101111 at index 538084
First prime Cyclop number > 10,000,000

<lang fsharp> let n=primeCyclops|>Seq.findIndex(fun n->n>10000000) in printfn "First prime Cyclop number > 10,000,000 is %d at index %d" (Seq.item n (primeCyclops)) n </lang>

Output:
First prime Cyclop number > 10,000,000 is 111101129 at index 39319
First blind Cyclop number > 10,000,000

<lang fsharp> let n=blindCyclops|>Seq.findIndex(fun n->n>10000000) in printfn "First blind Cyclop number > 10,000,000 is %d at index %d" (Seq.item n (blindCyclops)) n </lang>

Output:
First blind Cyclop number > 10,000,000 is 111101161 at index 11393
First palindromic prime Cyclop number > 10,000,000

<lang fsharp> let n=palindromicCyclops|>Seq.findIndex(fun n->n>10000000) in printfn "First palindromic prime Cyclop number > 10,000,000 is %d at index %d" (Seq.item n (palindromicCyclops)) n </lang>

Output:
First palindromic prime Cyclop number > 10,000,000 is 114808411 at index 66

Factor

An attempt to make it fast has resulted in a lot of code, but here's the basic idea. Cyclops numbers are stored in four parts: an integer representing whatever is to the left of the 0, a right integer, the number of digits in either side, and the maximum number with that many digits. For example, T{ cyclops f 33 34 2 99 } represents the number 33034. The left and right are zeroless; that is, they are not allowed to have any zeros.

In order to find the successor to a given cyclops number:

  • Increment the right integer to the next zeroless integer using the following formula (from OEIS):

       a(n+1) = f(a(n)) with f(x) = 1 + if x mod 10 < 9 then x else 10*f([x/10])

  • Unless right = max, in which case increment the left integer instead in the same manner, and reset the right integer back to max / 9.
  • Unless left = max, in which case we move up to the next order of magnitude by adding max/9 + 1 to both sides, adding 1 to the number of digits, and setting the new max as max := max * 10 + 9


Cyclops numbers in this form can be converted to integers (as late as possible) with int(c) = 10^(c.n + 1) * c.left + c.right

   where n is the number of digits in either side.

Cyclops numbers can be converted to blind form with the same formula without the + 1.


Works with: Factor version 0.99 2021-06-02

<lang factor>USING: accessors formatting grouping io kernel lists lists.lazy math math.functions math.primes prettyprint sequences tools.memory.private tools.time ;


! ==========={[ Cyclops data type and operations ]}=============

TUPLE: cyclops left right n max ;

<cyclops> ( -- cyclops ) 1 1 1 9 cyclops boa ;
>cyclops< ( cyclops -- right left n )
   [ right>> ] [ left>> ] [ n>> ] tri ;

M: cyclops >integer >cyclops< 1 + 10^ * + ;

>blind ( cyclops -- n ) >cyclops< 10^ * + ;
next-zeroless ( 9199 -- 9211 )
   dup 10 mod 9 < [ 10 /i next-zeroless 10 * ] unless 1 + ;
right++ ( cyclops -- cyclops' )
   [ next-zeroless ] change-right ; inline
left++ ( cyclops -- cyclops' )
   [ next-zeroless ] change-left [ 9 /i ] change-right ;
n++ ( cyclops -- cyclops' )
   [ 1 + ] change-n [ 10 * 9 + ] change-max ;
change-both ( cyclops quot -- cyclops' )
   [ change-left ] keep change-right ; inline
expand ( cyclops -- cyclops' )
   dup max>> 9 /i 1 + '[ _ + ] change-both n++ ;
carry ( cyclops -- cyclops' )
   dup [ left>> ] [ max>> ] bi < [ left++ ] [ expand ] if ;
succ ( cyclops -- next-cyclops )
   dup [ right>> ] [ max>> ] bi < [ right++ ] [ carry ] if ;


! ============{[ List definitions & operations ]}===============

lcyclops ( -- list ) <cyclops> [ succ ] lfrom-by ;
lcyclops-int ( -- list ) lcyclops [ >integer ] lmap-lazy ;
lprime-cyclops ( -- list )
   lcyclops-int [ prime? ] lfilter ;
lblind-prime-cyclops ( -- list )
   lcyclops [ >integer prime? ] lfilter
   [ >blind prime? ] lfilter ;
reverse-digits ( 123 -- 321 )
   0 swap [ 10 /mod rot 10 * + swap ] until-zero ;
lpalindromic-prime-cyclops ( -- list )
   lcyclops [ [ left>> ] [ right>> ] bi reverse-digits = ]
   lfilter [ >integer prime? ] lfilter ;
first>1e7 ( list -- elt index )
   0 lfrom lzip [ first >integer 10,000,000 > ] lfilter car
   first2 [ >integer ] dip [ commas ] bi@ ;


! ====================={[ OUTPUT ]}=============================

first50 ( list -- )
 50 swap ltake [ >integer ] lmap list>array 10 group
 simple-table. ;
show ( desc list -- )
   desc desc "First 50 %s numbers:\n" printf
   list [ first50 nl ] [
       first>1e7
       "First %s number > 10,000,000: %s - at (zero based) index: %s.\n\n\n" printf
   ] bi ;

"cyclops" lcyclops-int show "prime cyclops" lprime-cyclops show "blind prime cyclops" lblind-prime-cyclops show "palindromic prime cyclops" lpalindromic-prime-cyclops show

! Extra stretch? "One billionth cyclops number:" print 999,999,999 lcyclops lnth >integer commas print</lang>

Output:
First 50 cyclops numbers:
101 102 103 104 105 106 107 108 109 201
202 203 204 205 206 207 208 209 301 302
303 304 305 306 307 308 309 401 402 403
404 405 406 407 408 409 501 502 503 504
505 506 507 508 509 601 602 603 604 605

First cyclops number > 10,000,000: 111,101,111 - at (zero based) index: 538,083.


First 50 prime cyclops numbers:
101   103   107   109   307   401   409   503   509   601
607   701   709   809   907   11027 11047 11057 11059 11069
11071 11083 11087 11093 12011 12037 12041 12043 12049 12071
12073 12097 13033 13037 13043 13049 13063 13093 13099 14011
14029 14033 14051 14057 14071 14081 14083 14087 15013 15017

First prime cyclops number > 10,000,000: 111,101,129 - at (zero based) index: 39,319.


First 50 blind prime cyclops numbers:
101   103   107   109   307   401   503   509   601   607
701   709   809   907   11071 11087 11093 12037 12049 12097
13099 14029 14033 14051 14071 14081 14083 14087 15031 15053
15083 16057 16063 16067 16069 16097 17021 17033 17041 17047
17053 17077 18047 18061 18077 18089 19013 19031 19051 19073

First blind prime cyclops number > 10,000,000: 111,101,161 - at (zero based) index: 11,393.


First 50 palindromic prime cyclops numbers:
101     16061   31013   35053   38083   73037   74047   91019   94049   1120211
1150511 1160611 1180811 1190911 1250521 1280821 1360631 1390931 1490941 1520251
1550551 1580851 1630361 1640461 1660661 1670761 1730371 1820281 1880881 1930391
1970791 3140413 3160613 3260623 3310133 3380833 3460643 3470743 3590953 3670763
3680863 3970793 7190917 7250527 7310137 7540457 7630367 7690967 7750577 7820287

First palindromic prime cyclops number > 10,000,000: 114,808,411 - at (zero based) index: 66.


One billionth cyclops number:
35,296,098,111

Go

Translation of: Wren
Library: Go-rcu

<lang go>package main

import (

   "fmt"
   "rcu"
   "strconv"
   "strings"

)

func findFirst(list []int) (int, int) {

   for i, n := range list {
       if n > 1e7 {
           return n, i
       }
   }
   return -1, -1

}

func reverse(s string) string {

   chars := []rune(s)
   for i, j := 0, len(chars)-1; i < j; i, j = i+1, j-1 {
       chars[i], chars[j] = chars[j], chars[i]
   }
   return string(chars)

}

func main() {

   ranges := [][2]int{
       {0, 0}, {101, 909}, {11011, 99099}, {1110111, 9990999}, {111101111, 119101111},
   }
   var cyclops []int
   for _, r := range ranges {
       numDigits := len(fmt.Sprint(r[0]))
       center := numDigits / 2
       for i := r[0]; i <= r[1]; i++ {
           digits := rcu.Digits(i, 10)
           if digits[center] == 0 {
               count := 0
               for _, d := range digits {
                   if d == 0 {
                       count++
                   }
               }
               if count == 1 {
                   cyclops = append(cyclops, i)
               }
           }
       }
   }
   fmt.Println("The first 50 cyclops numbers are:")
   for i, n := range cyclops[0:50] {
       fmt.Printf("%6s ", rcu.Commatize(n))
       if (i+1)%10 == 0 {
           fmt.Println()
       }
   }
   n, i := findFirst(cyclops)
   ns, is := rcu.Commatize(n), rcu.Commatize(i)
   fmt.Printf("\nFirst such number > 10 million is %s at zero-based index %s\n", ns, is)
   var primes []int
   for _, n := range cyclops {
       if rcu.IsPrime(n) {
           primes = append(primes, n)
       }
   }
   fmt.Println("\n\nThe first 50 prime cyclops numbers are:")
   for i, n := range primes[0:50] {
       fmt.Printf("%6s ", rcu.Commatize(n))
       if (i+1)%10 == 0 {
           fmt.Println()
       }
   }
   n, i = findFirst(primes)
   ns, is = rcu.Commatize(n), rcu.Commatize(i)
   fmt.Printf("\nFirst such number > 10 million is %s at zero-based index %s\n", ns, is)
   var bpcyclops []int
   var ppcyclops []int
   for _, p := range primes {
       ps := fmt.Sprint(p)
       split := strings.Split(ps, "0")
       noMiddle, _ := strconv.Atoi(split[0] + split[1])
       if rcu.IsPrime(noMiddle) {
           bpcyclops = append(bpcyclops, p)
       }
       if ps == reverse(ps) {
           ppcyclops = append(ppcyclops, p)
       }
   }
   fmt.Println("\n\nThe first 50 blind prime cyclops numbers are:")
   for i, n := range bpcyclops[0:50] {
       fmt.Printf("%6s ", rcu.Commatize(n))
       if (i+1)%10 == 0 {
           fmt.Println()
       }
   }
   n, i = findFirst(bpcyclops)
   ns, is = rcu.Commatize(n), rcu.Commatize(i)
   fmt.Printf("\nFirst such number > 10 million is %s at zero-based index %s\n", ns, is)
   fmt.Println("\n\nThe first 50 palindromic prime cyclops numbers are:\n")
   for i, n := range ppcyclops[0:50] {
       fmt.Printf("%9s ", rcu.Commatize(n))
       if (i+1)%8 == 0 {
           fmt.Println()
       }
   }
   n, i = findFirst(ppcyclops)
   ns, is = rcu.Commatize(n), rcu.Commatize(i)
   fmt.Printf("\n\nFirst such number > 10 million is %s at zero-based index %s\n", ns, is)

}</lang>

Output:
The first 50 cyclops numbers are:
     0    101    102    103    104    105    106    107    108    109
   201    202    203    204    205    206    207    208    209    301
   302    303    304    305    306    307    308    309    401    402
   403    404    405    406    407    408    409    501    502    503
   504    505    506    507    508    509    601    602    603    604

First such number > 10 million is 111,101,111 at zero-based index 538,084


The first 50 prime cyclops numbers are:
   101    103    107    109    307    401    409    503    509    601
   607    701    709    809    907 11,027 11,047 11,057 11,059 11,069
11,071 11,083 11,087 11,093 12,011 12,037 12,041 12,043 12,049 12,071
12,073 12,097 13,033 13,037 13,043 13,049 13,063 13,093 13,099 14,011
14,029 14,033 14,051 14,057 14,071 14,081 14,083 14,087 15,013 15,017

First such number > 10 million is 111,101,129 at zero-based index 39,319


The first 50 blind prime cyclops numbers are:
   101    103    107    109    307    401    503    509    601    607
   701    709    809    907 11,071 11,087 11,093 12,037 12,049 12,097
13,099 14,029 14,033 14,051 14,071 14,081 14,083 14,087 15,031 15,053
15,083 16,057 16,063 16,067 16,069 16,097 17,021 17,033 17,041 17,047
17,053 17,077 18,047 18,061 18,077 18,089 19,013 19,031 19,051 19,073

First such number > 10 million is 111,101,161 at zero-based index 11,393


The first 50 palindromic prime cyclops numbers are:
      101    16,061    31,013    35,053    38,083    73,037    74,047    91,019
   94,049 1,120,211 1,150,511 1,160,611 1,180,811 1,190,911 1,250,521 1,280,821
1,360,631 1,390,931 1,490,941 1,520,251 1,550,551 1,580,851 1,630,361 1,640,461
1,660,661 1,670,761 1,730,371 1,820,281 1,880,881 1,930,391 1,970,791 3,140,413
3,160,613 3,260,623 3,310,133 3,380,833 3,460,643 3,470,743 3,590,953 3,670,763
3,680,863 3,970,793 7,190,917 7,250,527 7,310,137 7,540,457 7,630,367 7,690,967
7,750,577 7,820,287

First such number > 10 million is 114,808,411 at zero-based index 66

Haskell

<lang haskell>import Control.Monad (replicateM) import Data.Numbers.Primes (isPrime)


CYCLOPS NUMBERS --------------------

cyclops :: [Integer] cyclops = [0 ..] >>= flankingDigits

 where
   flankingDigits 0 = [0]
   flankingDigits n =
     fmap
       (\s -> read s :: Integer)
       ( (fmap ((<>) . (<> "0")) >>= (<*>))
           (replicateM n ['1' .. '9'])
       )


blindPrime :: Integer -> Bool blindPrime n =

 let s = show n
     m = quot (length s) 2
  in isPrime $
       (\s -> read s :: Integer)
         (take m s <> drop (succ m) s)


palindromic :: Integer -> Bool palindromic = ((==) =<< reverse) . show



TESTS -------------------------

main :: IO () main =

 (putStrLn . unlines)
   [ "First 50 Cyclops numbers – A134808:",
     unwords (show <$> take 50 cyclops),
     "",
     "First 50 Cyclops primes – A134809:",
     unwords $ take 50 [show n | n <- cyclops, isPrime n],
     "",
     "First 50 blind prime Cyclops numbers – A329737:",
     unwords $
       take
         50
         [show n | n <- cyclops, isPrime n, blindPrime n],
     "",
     "First 50 prime palindromic cyclops numbers – A136098:",
     unwords $
       take
         50
         [show n | n <- cyclops, isPrime n, palindromic n]
   ]</lang>
First 50 Cyclops numbers – A134808:
0 101 102 103 104 105 106 107 108 109 201 202 203 204 205 206 207 208 209 301 302 303 304 305 306 307 308 309 401 402 403 404 405 406 407 408 409 501 502 503 504 505 506 507 508 509 601 602 603 604

First 50 Cyclops primes – A134809:
101 103 107 109 307 401 409 503 509 601 607 701 709 809 907 11027 11047 11057 11059 11069 11071 11083 11087 11093 12011 12037 12041 12043 12049 12071 12073 12097 13033 13037 13043 13049 13063 13093 13099 14011 14029 14033 14051 14057 14071 14081 14083 14087 15013 15017

First 50 blind prime Cyclops numbers – A329737:
101 103 107 109 307 401 503 509 601 607 701 709 809 907 11071 11087 11093 12037 12049 12097 13099 14029 14033 14051 14071 14081 14083 14087 15031 15053 15083 16057 16063 16067 16069 16097 17021 17033 17041 17047 17053 17077 18047 18061 18077 18089 19013 19031 19051 19073

First 50 prime palindromic cyclops numbers – A136098:
101 16061 31013 35053 38083 73037 74047 91019 94049 1120211 1150511 1160611 1180811 1190911 1250521 1280821 1360631 1390931 1490941 1520251 1550551 1580851 1630361 1640461 1660661 1670761 1730371 1820281 1880881 1930391 1970791 3140413 3160613 3260623 3310133 3380833 3460643 3470743 3590953 3670763 3680863 3970793 7190917 7250527 7310137 7540457 7630367 7690967 7750577 7820287

Julia

Julia's indexes are 1 based, hence one greater than those of 0 based indices. <lang julia> print5x10(a, w = 8) = for i in 0:4, j in 1:10 print(lpad(a[10i + j], w), j == 10 ? "\n" : "") end

function iscyclops(n)

   d = digits(n)
   l = length(d)
   return isodd(l) && d[l ÷ 2 + 1] == 0 && count(x -> x == 0, d) == 1

end

function isblindprimecyclops(n)

   d = digits(n)
   l = length(d)
   m = l ÷ 2 + 1
   (n == 0 || iseven(l) || d[m] != 0 || count(x -> x == 0, d) != 1) && return false
   return isprime(evalpoly(10, [d[1:m-1]; d[m+1:end]]))

end

function ispalindromicprimecyclops(n)

   d = digits(n)
   l = length(d)
   return n > 0 && isodd(l) && d[l ÷ 2 + 1] == 0 && count(x -> x == 0, d) == 1 && d == reverse(d)

end

function findcyclops(N, iscycs, nextcandidate)

   i, list = nextcandidate(-1), Int[]
   while length(list) < N
       iscycs(i) && push!(list, i)
       i = nextcandidate(i)
   end
   return list

end

function nthcyclopsfirstafter(lowerlimit, iscycs, nextcandidate)

   i, found = 0, 0
   while true
       if iscycs(i)
           found += 1
           i >= lowerlimit && break
       end
       i = nextcandidate(i)
   end
   return i, found

end

function testcyclops()

   println("The first 50 cyclops numbers are:")
   print5x10(findcyclops(50, iscyclops, x -> x + 1))
   n, c = nthcyclopsfirstafter(10000000, iscyclops, x -> x + 1)
   println("\nThe next cyclops number after 10,000,000 is $n at position $c.")
   println("\nThe first 50 prime cyclops numbers are:")
   print5x10(findcyclops(50, iscyclops, x -> nextprime(x + 1)))
   n, c = nthcyclopsfirstafter(10000000, iscyclops, x -> nextprime(x + 1))
   println("\nThe next prime cyclops number after 10,000,000 is $n at position $c.")
   println("\nThe first 50 blind prime cyclops numbers are:")
   print5x10(findcyclops(50, isblindprimecyclops, x -> nextprime(x + 1)))
   n, c = nthcyclopsfirstafter(10000000, isblindprimecyclops, x -> nextprime(x + 1))
   println("\nThe next prime cyclops number after 10,000,000 is $n at position $c.")
   println("\nThe first 50 palindromic prime cyclops numbers are:")
   print5x10(findcyclops(50, ispalindromicprimecyclops, x -> nextprime(x + 1)))
   n, c = nthcyclopsfirstafter(10000000, ispalindromicprimecyclops, x -> nextprime(x + 1))
   println("\nThe next prime cyclops number after 10,000,000 is $n at position $c.")

end

testcyclops()

</lang>

Output:
The first 50 cyclops numbers are:
       0     101     102     103     104     105     106     107     108     109
     201     202     203     204     205     206     207     208     209     301
     302     303     304     305     306     307     308     309     401     402
     403     404     405     406     407     408     409     501     502     503
     504     505     506     507     508     509     601     602     603     604

The next cyclops number after 10,000,000 is 111101111 at position 538085.

The first 50 prime cyclops numbers are:
     101     103     107     109     307     401     409     503     509     601
     607     701     709     809     907   11027   11047   11057   11059   11069
   11071   11083   11087   11093   12011   12037   12041   12043   12049   12071
   12073   12097   13033   13037   13043   13049   13063   13093   13099   14011
   14029   14033   14051   14057   14071   14081   14083   14087   15013   15017

The next prime cyclops number after 10,000,000 is 111101129 at position 39321.

The first 50 blind prime cyclops numbers are:
     101     103     107     109     307     401     503     509     601     607
     701     709     809     907   11071   11087   11093   12037   12049   12097
   13099   14029   14033   14051   14071   14081   14083   14087   15031   15053
   15083   16057   16063   16067   16069   16097   17021   17033   17041   17047
   17053   17077   18047   18061   18077   18089   19013   19031   19051   19073

The next prime cyclops number after 10,000,000 is 111101161 at position 11394.

The first 50 palindromic prime cyclops numbers are:
     101   16061   31013   35053   38083   73037   74047   91019   94049 1120211
 1150511 1160611 1180811 1190911 1250521 1280821 1360631 1390931 1490941 1520251
 1550551 1580851 1630361 1640461 1660661 1670761 1730371 1820281 1880881 1930391
 1970791 3140413 3160613 3260623 3310133 3380833 3460643 3470743 3590953 3670763
 3680863 3970793 7190917 7250527 7310137 7540457 7630367 7690967 7750577 7820287

The next prime cyclops number after 10,000,000 is 114808411 at position 67.

Nim

<lang Nim>import strutils, times

const Ranges = [0..0, 101..909, 11011..99099, 1110111..9990999, 111101111..999909999]


func isCyclops(d: string): bool =

 d[d.len shr 1] == '0' and d.count('0') == 1

func isPrime(n: Natural): bool =

 if n < 2: return
 if n mod 2 == 0: return n == 2
 if n mod 3 == 0: return n == 3
 var d = 5
 while d * d <= n:
   if n mod d == 0: return false
   inc d, 2
   if n mod d == 0: return false
   inc d, 4
 return true

func isBlind(d: string): bool =

 var d = d
 let m = d.len shr 1
 result = (d[0..m-1] & d[m+1..^1]).parseInt().isPrime

func isPalindromic(d: string): bool =

 for i in 1..d.len:
   if d[i-1] != d[^i]: return
 result = true


iterator cyclops(): (int, int) =

 var count = 0
 for r in Ranges:
   for n in r:
     if ($n).isCyclops:
       inc count
       yield (count, n)

iterator primeCyclops(): (int, int) =

 var count = 0
 for (_, n) in cyclops():
   if n.isPrime:
     inc count
     yield (count, n)

iterator blindPrimeCyclops(): (int, int) =

 var count = 0
 for (_, n) in primeCyclops():
   if ($n).isBlind:
     inc count
     yield (count, n)

iterator palindromicPrimeCyclops(): (int, int) =

 var count = 0
 for r in Ranges:
   for n in r:
     let d = $n
     if d.isCyclops and d.isPalindromic and n.isPrime:
       inc count
       yield (count, n)

let t0 = cpuTime()

echo "List of first 50 cyclops numbers:" for i, n in cyclops():

 stdout.write ($n).align(3), if i mod 10 == 0: '\n' else: ' '
 if i == 50: break

echo "\nList of first 50 prime cyclops numbers:" for i, n in primeCyclops():

 stdout.write ($n).align(5), if i mod 10 == 0: '\n' else: ' '
 if i == 50: break

echo "\nList of first 50 blind prime cyclops numbers:" for i, n in blindPrimeCyclops():

 stdout.write ($n).align(5), if i mod 10 == 0: '\n' else: ' '
 if i == 50: break

echo "\nList of first 50 palindromic prime cyclops numbers:" for i, n in palindromicPrimeCyclops():

 stdout.write ($n).align(7), if i mod 10 == 0: '\n' else: ' '
 if i == 50: break

for i, n in cyclops():

 if n > 10_000_000:
   echo "\nFirst cyclops number greater than ten million is ",
        ($n).insertSep(), " at 1-based index: ", i
   break

for i, n in primeCyclops():

 if n > 10_000_000:
   echo "\nFirst prime cyclops number greater than ten million is ",
        ($n).insertSep(), " at 1-based index: ", i
   break

for i, n in blindPrimeCyclops():

 if n > 10_000_000:
   echo "\nFirst blind prime cyclops number greater than ten million is ",
        ($n).insertSep(), " at 1-based index: ", i
   break

for i, n in palindromicPrimeCyclops():

 if n > 10_000_000:
   echo "\nFirst palindromic prime cyclops number greater than ten million is ",
        ($n).insertSep(), " at 1-based index: ", i
   break

echo "\nExecution time: ", (cpuTime() - t0).formatFloat(ffDecimal, precision = 3), " seconds."</lang>

Output:
List of first 50 cyclops numbers:
  0 101 102 103 104 105 106 107 108 109
201 202 203 204 205 206 207 208 209 301
302 303 304 305 306 307 308 309 401 402
403 404 405 406 407 408 409 501 502 503
504 505 506 507 508 509 601 602 603 604

List of first 50 prime cyclops numbers:
  101   103   107   109   307   401   409   503   509   601
  607   701   709   809   907 11027 11047 11057 11059 11069
11071 11083 11087 11093 12011 12037 12041 12043 12049 12071
12073 12097 13033 13037 13043 13049 13063 13093 13099 14011
14029 14033 14051 14057 14071 14081 14083 14087 15013 15017

List of first 50 blind prime cyclops numbers:
  101   103   107   109   307   401   503   509   601   607
  701   709   809   907 11071 11087 11093 12037 12049 12097
13099 14029 14033 14051 14071 14081 14083 14087 15031 15053
15083 16057 16063 16067 16069 16097 17021 17033 17041 17047
17053 17077 18047 18061 18077 18089 19013 19031 19051 19073

List of first 50 palindromic prime cyclops numbers:
    101   16061   31013   35053   38083   73037   74047   91019   94049 1120211
1150511 1160611 1180811 1190911 1250521 1280821 1360631 1390931 1490941 1520251
1550551 1580851 1630361 1640461 1660661 1670761 1730371 1820281 1880881 1930391
1970791 3140413 3160613 3260623 3310133 3380833 3460643 3470743 3590953 3670763
3680863 3970793 7190917 7250527 7310137 7540457 7630367 7690967 7750577 7820287

First cyclops number greater than ten million is 111_101_111 at 1-based index: 538085

First prime cyclops number greater than ten million is 111_101_129 at 1-based index: 39320

First blind prime cyclops number greater than ten million is 111_101_161 at 1-based index: 11394

First palindromic prime cyclops number greater than ten million is 114_808_411 at 1-based index: 67

Execution time: 2.936 seconds.

Pascal

simple trial division for isprime is very slow.
Try to find one billionth like Cyclops_numbers#Factor <lang pascal>program cyclops; {$IFDEF FPC}

 {$MODE DELPHI}
 {$OPTIMIZATION ON,ALL}

{$ENDIF} uses

 sysutils;

type

 //number in base 9
 tnumdgts = array[0..10] of byte;
 tpnumdgts = pByte;
 tnum9 = packed record
          nmdgts : tnumdgts;
          nmMaxDgtIdx :byte;
          nmNum  : uint32;
        end;
 tCN = record
         cnRight,
         cnLeft :  tNum9;
         cnNum  :  Uint64;
         cndigits :  Uint32;
       end;

var

 cnMin,cnPow : array[0..19] of Uint64;

function isPrime(n:Uint32):boolean; var

 p,q : Uint32;

Begin

 if n< 4 then
 Begin
   if n < 2 then
     EXIT(false);
   EXIT(true);
 end;
 if (n AND 1 = 0) then
   EXIT(false);
 if n = 5 then
   exit(true);
 if n mod 3 = 0 then
   EXIT(false);
 p := 5;
 repeat
   q := n div p;
   if n-q*p = 0 then
     EXIT(false);
   if q < p then
     break;
   p += 2;
   q := n div p;
   if n-q*p = 0 then
     EXIT(false);
   if q < p then
     break;
   p += 4;
 until false;
 EXIT(true);

end;

procedure InitCnMinPow; //min = (0,1,11,111,1111,11111,111111,1111111,11111111,...); var

 i,min,pow : Uint64;

begin

 min := 0;
 pow := 100;
 For i :=0 to High(cnMin) do
 begin
   cnMin[i] := min;
   min := 10*min+1;
   cnPow[i] := pow;
   pow *= 10;
 end;

end;

procedure ClearNum9(var tn:tNum9;idx:Uint32); begin

 fillchar(tn,SizeOf(tn),#0);
 tn.nmNum := cnMin[idx+1];

end;

Procedure InitCycNum(var cn:tCN); Begin

 with cn do
 Begin
   cndigits := 0;
   ClearNum9(cnLeft,0);
   ClearNum9(cnRight,0);
   cnNum := 101;
 end;

end;

procedure IncNum9(var tn:tNum9); var

 idx,fac,n: Uint32;

begin

 idx := 0;
 with tn do
 Begin
   fac := 1;
   n := nmdgts[0]+1;
   inc(nmNum);
   repeat
     if n < 9 then
       break;
     inc(nmNum,fac);
     nmdgts[idx] :=0;
     inc(idx);
     fac *= 10;
     n := nmdgts[idx]+1;
   until idx > nmMaxDgtIdx;
   If idx > High(nmdgts) then
     EXIT;
   nmdgts[idx] := n;
   if nmMaxDgtIdx<Idx then
     nmMaxDgtIdx := Idx;
 end;

end;

function RevCycNum(const cycnum:tCN):Uint64; var

 i:Uint32;

Begin

 result := 0;
 with cycnum do
 Begin
   For i := 0 to cnDigits do
     result := 10*result+cnRight.nmdgts[i]+1;
   result *=10;
   For i := 0 to cnDigits do
     result := 10*result+cnLeft.nmdgts[i]+1;
 end;

end;

procedure NextCycNum(var cycnum:tCN); begin

 with cycnum do
 Begin
   IncNum9(cnRight);
   if cnRight.nmMaxDgtIdx > cndigits then
   Begin
     ClearNum9(cnRight,cndigits);
     IncNum9(cnLeft);
     if cnLeft.nmMaxDgtIdx > cndigits then
     Begin
       inc(cndigits);
       ClearNum9(cnLeft,cndigits);
       ClearNum9(cnRight,cndigits);
       if cndigits>High(tnumdgts) then
         cndigits := High(tnumdgts);
     end;
   end;
   cnNum := cnLeft.nmNum*cnPow[cndigits]+cnRight.nmNUm;
 end;

end;

var

 cycnum:tCN;
 n,cnt : NativeUint;
 isPr : boolean;

begin

 InitCnMinPow;
 cnt := 1;
 write(0:4);
 InitCycNum(cycnum);
 repeat
   write(cycnum.cnNum:4);
   NextCycNum(cycnum);
   inc(cnt);
   if cnt mod 10 = 0 then
     writeln;
 until cnt = 50;
 writeln;
 repeat
   NextCycNum(cycnum);
   inc(cnt);
 until cycnum.cnNum> 10*1000*1000;
 //9 ^ (2*digits used) 
 writeln(cycnum.cnNum,' at index ',cnt,' = 9^(2*3)+9^(2*2)+9^(2*1)+1');
 writeln;
 cnt := 0;
 InitCycNum(cycnum);
 repeat
   if isPrime(cycnum.cnNum) then
   Begin
     write(cycnum.cnNum:6);
     inc(cnt);
     if cnt mod 10 = 0 then
       writeln;
   end;
   NextCycNum(cycnum);
 until cnt = 50;
 writeln;
 cnt := 0;
 InitCycNum(cycnum);
 repeat
   n := cycnum.cnNum;
   if isPrime(n) then
   begin;
     inc(cnt);
     if n > 10*1000*1000 then
       BREAK;
   end;
   NextCycNum(cycnum);
 until false;
 writeln(n,' at index ',cnt);
 writeln;
 cnt := 0;
 InitCycNum(cycnum);
 repeat
   with cycnum do
     if isPrime(cnNum) then
     Begin
       n := cnLeft.nmNum*cnPow[cndigits] DIV 10+cnRight.nmNum;
       if isPrime(n) then
       Begin
         write(cnNum:6);
         inc(cnt);
         if cnt mod 10 = 0 then
          writeln;
       end;
     end;
   NextCycNum(cycnum);
 until cnt = 50;
 writeln;
 cnt := 0;
 InitCycNum(cycnum);
 repeat
   with cycnum do
     if isPrime(cnNum) then
     Begin
       n := cnLeft.nmNum*cnPow[cndigits] DIV 10+cnRight.nmNum;
       isPr:= isPrime(n);
       inc(cnt,Ord(isPr));
       if (cycnum.cnNum > 10*1000*1000) then
         BREAK;
     end;
   NextCycNum(cycnum);
 until false;
 writeln(cycnum.cnNum,' at index ',cnt);
 writeln;


 cnt := 0;
 InitCycNum(cycnum);
 repeat
   with cycnum do
     if RevCycNum(cycNum) = cnNum then
       if isPrime(cnNum) then
       Begin
         write(cnNum:8);
         inc(cnt);
         if cnt mod 10 = 0 then
          writeln;
       end;
   NextCycNum(cycnum);
 until cnt = 50;
 writeln;
 repeat
   with cycnum do
     if RevCycNum(cycNum) = cnNum then
       if isPrime(cnNum) then
       Begin
         inc(cnt);
         if cycnum.cnNum > 10*1000*1000 then
           BREAK;
       end;
   NextCycNum(cycnum);
 until false;
 writeln(cycnum.cnNum,' at index ',cnt);
 writeln;
 cnt := 1;
 InitCycNum(cycnum);
 repeat
   NextCycNum(cycnum);
   inc(cnt);
 until cnt = 1000*1000*1000;
 writeln;
 writeln(cnt,'.th = ',cycnum.cnNum);

end.</lang>

Output:
TIO.RUN
   0 101 102 103 104 105 106 107 108 109
 201 202 203 204 205 206 207 208 209 301
 302 303 304 305 306 307 308 309 401 402
 403 404 405 406 407 408 409 501 502 503
 504 505 506 507 508 509 601 602 603 604

111101111 at index 538084 = 9^(2*3)+9^(2*2)+9^(2*1)+1

   101   103   107   109   307   401   409   503   509   601
   607   701   709   809   907 11027 11047 11057 11059 11069
 11071 11083 11087 11093 12011 12037 12041 12043 12049 12071
 12073 12097 13033 13037 13043 13049 13063 13093 13099 14011
 14029 14033 14051 14057 14071 14081 14083 14087 15013 15017

111101129 at index 39320

   101   103   107   109   307   401   503   509   601   607
   701   709   809   907 11071 11087 11093 12037 12049 12097
 13099 14029 14033 14051 14071 14081 14083 14087 15031 15053
 15083 16057 16063 16067 16069 16097 17021 17033 17041 17047
 17053 17077 18047 18061 18077 18089 19013 19031 19051 19073

111101129 at index 11393

     101   16061   31013   35053   38083   73037   74047   91019   94049 1120211
 1150511 1160611 1180811 1190911 1250521 1280821 1360631 1390931 1490941 1520251
 1550551 1580851 1630361 1640461 1660661 1670761 1730371 1820281 1880881 1930391
 1970791 3140413 3160613 3260623 3310133 3380833 3460643 3470743 3590953 3670763
 3680863 3970793 7190917 7250527 7310137 7540457 7630367 7690967 7750577 7820287

114808411 at index 67

1000000000.th = 35296098111 // takes ~4.6 sec 

Real time: 5.378 s CPU share: 98.10 %

Perl

Translation of: Raku
Library: ntheory

<lang perl>use strict; use warnings; use feature 'say'; use ntheory 'is_prime'; use List::AllUtils 'firstidx';

sub comma { reverse ((reverse shift) =~ s/(.{3})/$1,/gr) =~ s/^,//r }

my @cyclops = 0; for my $exp (0..3) {

   my @oom = grep { ! /0/ } 10**$exp .. 10**($exp+1)-1;
   for my $l (@oom) {
       for my $r (@oom) {
           push @cyclops, $l . '0' . $r;
       }
   }

}

my @prime_cyclops = grep { is_prime $_ } @cyclops; my @prime_blind = grep { is_prime $_ =~ s/0//r } @prime_cyclops; my @prime_palindr = grep { $_ eq reverse $_ } @prime_cyclops;

my $upto = 50; my $over = 10_000_000;

for (

 [, @cyclops],
 ['prime', @prime_cyclops],
 ['blind prime', @prime_blind],
 ['palindromic prime', @prime_palindr]) {
   my($text,@values) = @$_;
   my $i = firstidx { $_ > $over } @values;
   say "First $upto $text cyclops numbers:\n" .
       (sprintf "@{['%8d' x $upto]}", @values[0..$upto-1]) =~ s/(.{80})/$1\n/gr;
   printf "First $text number > %s: %s at (zero based) index: %s\n\n", map { comma($_) } $over, $values[$i], $i;

}</lang>

Output:
First 50  cyclops numbers:
       0     101     102     103     104     105     106     107     108     109
     201     202     203     204     205     206     207     208     209     301
     302     303     304     305     306     307     308     309     401     402
     403     404     405     406     407     408     409     501     502     503
     504     505     506     507     508     509     601     602     603     604

First  number > 10,000,000: 111,101,111 at (zero based) index: 538,084

First 50 prime cyclops numbers:
     101     103     107     109     307     401     409     503     509     601
     607     701     709     809     907   11027   11047   11057   11059   11069
   11071   11083   11087   11093   12011   12037   12041   12043   12049   12071
   12073   12097   13033   13037   13043   13049   13063   13093   13099   14011
   14029   14033   14051   14057   14071   14081   14083   14087   15013   15017

First prime number > 10,000,000: 111,101,129 at (zero based) index: 39,319

First 50 blind prime cyclops numbers:
     101     103     107     109     307     401     503     509     601     607
     701     709     809     907   11071   11087   11093   12037   12049   12097
   13099   14029   14033   14051   14071   14081   14083   14087   15031   15053
   15083   16057   16063   16067   16069   16097   17021   17033   17041   17047
   17053   17077   18047   18061   18077   18089   19013   19031   19051   19073

First blind prime number > 10,000,000: 111,101,161 at (zero based) index: 11,393

First 50 palindromic prime cyclops numbers:
     101   16061   31013   35053   38083   73037   74047   91019   94049 1120211
 1150511 1160611 1180811 1190911 1250521 1280821 1360631 1390931 1490941 1520251
 1550551 1580851 1630361 1640461 1660661 1670761 1730371 1820281 1880881 1930391
 1970791 3140413 3160613 3260623 3310133 3380833 3460643 3470743 3590953 3670763
 3680863 3970793 7190917 7250527 7310137 7540457 7630367 7690967 7750577 7820287

First palindromic prime number > 10,000,000: 114,808,411 at (zero based) index: 66

Phix

Library: Phix/online

You can run this online here (expect a blank screen for about 8s).

with javascript_semantics
atom t0 = time()
function bump(sequence half)
    -- add a digit to valid halves
    -- eg {0} --> {1..9} (no zeroes)
    --        --> {11..99} ("")
    --        --> {111..999}, etc
    sequence res = {}
    for i=1 to length(half) do
        integer hi = half[i]*10
        for digit=1 to 9 do
            res &= hi+digit
        end for
    end for
    return res
end function

procedure cyclops(string s="")
    sequence res = {},
             half = {0} -- valid digits, see bump()
    integer left = 1,   -- half[] before the 0
            right = 0,  -- half[] after the 0
            hlen = 1,   -- length(half)
            cpow = 10,  -- cyclops power (of 10)
            bcpow = 1,  -- blind cyclops power
            cn = 0      -- cyclops number (scratch)
    bool valid = false,
         bPrime = match("prime",s),
         bBlind = match("blind",s),
         bPalin = match("palindromic",s)
    while length(res)<50 or cn<=1e7 or not valid do
        right += 1
        if right>hlen then
            right = 1
            left += 1
            if left>hlen then
                half = bump(half)
                hlen = length(half)
                cpow *= 10
                bcpow *= 10
                left = 1
            end if
        end if
        integer lh = half[left],
                rh = half[right]
        cn = lh*cpow+rh -- cyclops number
        valid = not bPrime or is_prime(cn)
        if valid and bBlind then
            valid = is_prime(lh*bcpow+rh)
        end if
        if valid and bPalin then
            valid = sprintf("%d",lh) == reverse(sprintf("%d",rh))
        end if
        if valid then
            res = append(res,sprintf("%7d",cn))
        end if
    end while
    printf(1,"First 50 %scyclops numbers:\n%s\n",{s,join_by(res[1..50],1,10)})
    printf(1,"First %scyclops number > 10,000,000: %s at (one based) index: %d\n\n",
             {s,res[$],length(res)})
end procedure

cyclops()
cyclops("prime ")
cyclops("blind prime ")
cyclops("palindromic prime ")
?elapsed(time()-t0)
Output:
First 50 cyclops numbers:
      0       101       102       103       104       105       106       107       108       109
    201       202       203       204       205       206       207       208       209       301
    302       303       304       305       306       307       308       309       401       402
    403       404       405       406       407       408       409       501       502       503
    504       505       506       507       508       509       601       602       603       604

First cyclops number > 10,000,000: 111101111 at (one based) index: 538085

First 50 prime cyclops numbers:
    101       103       107       109       307       401       409       503       509       601
    607       701       709       809       907     11027     11047     11057     11059     11069
  11071     11083     11087     11093     12011     12037     12041     12043     12049     12071
  12073     12097     13033     13037     13043     13049     13063     13093     13099     14011
  14029     14033     14051     14057     14071     14081     14083     14087     15013     15017

First prime cyclops number > 10,000,000: 111101129 at (one based) index: 39320

First 50 blind prime cyclops numbers:
    101       103       107       109       307       401       503       509       601       607
    701       709       809       907     11071     11087     11093     12037     12049     12097
  13099     14029     14033     14051     14071     14081     14083     14087     15031     15053
  15083     16057     16063     16067     16069     16097     17021     17033     17041     17047
  17053     17077     18047     18061     18077     18089     19013     19031     19051     19073

First blind prime cyclops number > 10,000,000: 111101161 at (one based) index: 11394

First 50 palindromic prime cyclops numbers:
    101     16061     31013     35053     38083     73037     74047     91019     94049   1120211
1150511   1160611   1180811   1190911   1250521   1280821   1360631   1390931   1490941   1520251
1550551   1580851   1630361   1640461   1660661   1670761   1730371   1820281   1880881   1930391
1970791   3140413   3160613   3260623   3310133   3380833   3460643   3470743   3590953   3670763
3680863   3970793   7190917   7250527   7310137   7540457   7630367   7690967   7750577   7820287

First palindromic prime cyclops number > 10,000,000: 114808411 at (one based) index: 67

"7.6s"

Raku

<lang perl6>use Lingua::EN::Numbers;

my @cyclops = 0, |flat lazy ^∞ .map: -> $exp {

     my @oom = (exp($exp, 10) ..^ exp($exp + 1, 10)).grep: { !.contains: 0 }
     |@oom.hyper.map: { $_ ~ 0 «~« @oom }

}

my @prime-cyclops = @cyclops.grep: { .is-prime };

for , @cyclops,

   'prime ',             @prime-cyclops,
   'blind prime ',       @prime-cyclops.grep( { .trans('0' => ).is-prime } ),
   'palindromic prime ', @prime-cyclops.grep( { $_ eq .flip } )
 -> $type, $iterator {
   say "\n\nFirst 50 {$type}cyclops numbers:\n" ~ $iterator[^50].batch(10)».fmt("%7d").join("\n") ~
       "\n\nFirst {$type}cyclops number > 10,000,000: " ~ comma($iterator.first: * > 1e7 ) ~
       " - at (zero based) index: " ~ comma $iterator.first: * > 1e7, :k;

}</lang>

Output:
First 50 cyclops numbers:
      0     101     102     103     104     105     106     107     108     109
    201     202     203     204     205     206     207     208     209     301
    302     303     304     305     306     307     308     309     401     402
    403     404     405     406     407     408     409     501     502     503
    504     505     506     507     508     509     601     602     603     604

First cyclops number > 10,000,000: 111,101,111 - at (zero based) index: 538,084


First 50 prime cyclops numbers:
    101     103     107     109     307     401     409     503     509     601
    607     701     709     809     907   11027   11047   11057   11059   11069
  11071   11083   11087   11093   12011   12037   12041   12043   12049   12071
  12073   12097   13033   13037   13043   13049   13063   13093   13099   14011
  14029   14033   14051   14057   14071   14081   14083   14087   15013   15017

First prime cyclops number > 10,000,000: 111,101,129 - at (zero based) index: 39,319


First 50 blind prime cyclops numbers:
    101     103     107     109     307     401     503     509     601     607
    701     709     809     907   11071   11087   11093   12037   12049   12097
  13099   14029   14033   14051   14071   14081   14083   14087   15031   15053
  15083   16057   16063   16067   16069   16097   17021   17033   17041   17047
  17053   17077   18047   18061   18077   18089   19013   19031   19051   19073

First blind prime cyclops number > 10,000,000: 111,101,161 - at (zero based) index: 11,393


First 50 palindromic prime cyclops numbers:
    101   16061   31013   35053   38083   73037   74047   91019   94049 1120211
1150511 1160611 1180811 1190911 1250521 1280821 1360631 1390931 1490941 1520251
1550551 1580851 1630361 1640461 1660661 1670761 1730371 1820281 1880881 1930391
1970791 3140413 3160613 3260623 3310133 3380833 3460643 3470743 3590953 3670763
3680863 3970793 7190917 7250527 7310137 7540457 7630367 7690967 7750577 7820287

First palindromic prime cyclops number > 10,000,000: 114,808,411 - at (zero based) index: 66

REXX

<lang rexx>/*REXX pgm finds 1st N cyclops (Θ) #s, Θ primes, blind Θ primes, palindromic Θ primes*/ parse arg n cols . /*obtain optional argument from the CL.*/ if n== | n=="," then n= 50 /*Not specified? Then use the default.*/ if cols== | cols=="," then cols= 10 /* " " " " " " */ call genP /*build array of semaphores for primes.*/ w= max(10, length( commas(@.#) ) ) /*max width of a number in any column. */ pri?= 0; bli?= 0; pal?= 0; call 0 ' first ' commas(n) " cyclops numbers" pri?= 1; bli?= 0; pal?= 0; call 0 ' first ' commas(n) " prime cyclops numbers" pri?= 1; bli?= 1; pal?= 0; call 0 ' first ' commas(n) " blind prime cyclops numbers" pri?= 1; bli?= 0; pal?= 1; call 0 ' first ' commas(n) " palindromic prime cyclops numbers" exit 0 /*stick a fork in it, we're all done. */ /*──────────────────────────────────────────────────────────────────────────────────────*/ commas: parse arg ?; do jc=length(?)-3 to 1 by -3; ?=insert(',', ?, jc); end; return ? /*──────────────────────────────────────────────────────────────────────────────────────*/ 0: parse arg title; idx= 1 /*get the title of this output section.*/

  say ' index │'center(title,   1 + cols*(w+1)     )
  say '───────┼'center(""   ,   1 + cols*(w+1), '─')
                  finds= 0;                 $=  /*the number of finds (so far); $ list.*/
    do j=0  until finds== n;      L= length(j)  /*find N cyclops numbers, start at 101.*/
    if L//2==0  then do;    j= left(1, L+1, 0)  /*Is J an even # of digits? Yes, bump J*/
                                       iterate  /*use a new J that has odd # of digits.*/
                     end
    z= pos(0, j);  if z\==(L+1)%2 then iterate  /* "  "    "    " (zero in mid)?    "  */
    if pos(0, j, z+1)>0           then iterate  /* "  "    "    " (has two 0's)?    "  */
    if pri?  then if \!.j         then iterate  /*Need a cyclops prime?      Then skip.*/
    if bli?  then do;   ?= space(translate(j, , 0), 0)   /*Need a blind cyclops prime ?*/
                        if \!.?   then iterate  /*Not a blind cyclops prime? Then skip.*/
                  end
    if pal?  then do;   r= reverse(j)           /*Need a palindromic cyclops prime?    */
                        if r\==j  then iterate  /*Cyclops number not palindromic? Skip.*/
                        if \!.r   then iterate  /*   "    palindrome not prime?     "  */
                  end
    finds= finds + 1                            /*bump the number of palindromic primes*/
    $= $ right( commas(j), w)                   /*add a palindromic prime ──►  $  list.*/
    if finds//cols\==0            then iterate  /*have we populated a line of output?  */
    say center(idx, 7)'│'  substr($, 2);    $=  /*display what we have so far  (cols). */
    idx= idx + cols                             /*bump the  index  count for the output*/
    end   /*j*/
  if $\==  then say center(idx, 7)"│"  substr($, 2)  /*possible show residual output.*/
  say '───────┴'center(""  ,   1 + cols*(w+1), '─');  say
  return

/*──────────────────────────────────────────────────────────────────────────────────────*/ genP: !.= 0; hip= 8000000 - 1 /*placeholders for primes (semaphores).*/

     @.1=2;  @.2=3;  @.3=5;  @.4=7;  @.5=11     /*define some low primes.              */
     !.2=1;  !.3=1;  !.5=1;  !.7=1;  !.11=1     /*   "     "   "    "     flags.       */
                     #=5;     s.#= @.# **2      /*number of primes so far;     prime². */
       do j=@.#+2  by 2  to hip                 /*find odd primes from here on.        */
       parse var j  -1 _; if     _==5  then iterate  /*J divisible by 5?  (right dig)*/
                            if j// 3==0  then iterate  /*"     "      " 3?             */
                            if j// 7==0  then iterate  /*"     "      " 7?             */
              do k=5  while s.k<=j              /* [↓]  divide by the known odd primes.*/
              if j // @.k == 0  then iterate j  /*Is  J ÷ X?  Then not prime.     ___  */
              end   /*k*/                       /* [↑]  only process numbers  ≤  √ J   */
       #= #+1;    @.#= j;    s.#= j*j;   !.j= 1 /*bump # of Ps; assign next P;  P²; P# */
       end          /*j*/;               return</lang>
output   when using the default inputs:
 index │                                           first  50  cyclops numbers
───────┼───────────────────────────────────────────────────────────────────────────────────────────────────────────────
   1   │          0        101        102        103        104        105        106        107        108        109
  11   │        201        202        203        204        205        206        207        208        209        301
  21   │        302        303        304        305        306        307        308        309        401        402
  31   │        403        404        405        406        407        408        409        501        502        503
  41   │        504        505        506        507        508        509        601        602        603        604
───────┴───────────────────────────────────────────────────────────────────────────────────────────────────────────────


 index │                                        first  50  prime cyclops numbers
───────┼───────────────────────────────────────────────────────────────────────────────────────────────────────────────
   1   │        101        103        107        109        307        401        409        503        509        601
  11   │        607        701        709        809        907     11,027     11,047     11,057     11,059     11,069
  21   │     11,071     11,083     11,087     11,093     12,011     12,037     12,041     12,043     12,049     12,071
  31   │     12,073     12,097     13,033     13,037     13,043     13,049     13,063     13,093     13,099     14,011
  41   │     14,029     14,033     14,051     14,057     14,071     14,081     14,083     14,087     15,013     15,017
───────┴───────────────────────────────────────────────────────────────────────────────────────────────────────────────


 index │                                     first  50  blind prime cyclops numbers
───────┼───────────────────────────────────────────────────────────────────────────────────────────────────────────────
   1   │        101        103        107        109        307        401        503        509        601        607
  11   │        701        709        809        907     11,071     11,087     11,093     12,037     12,049     12,097
  21   │     13,099     14,029     14,033     14,051     14,071     14,081     14,083     14,087     15,031     15,053
  31   │     15,083     16,057     16,063     16,067     16,069     16,097     17,021     17,033     17,041     17,047
  41   │     17,053     17,077     18,047     18,061     18,077     18,089     19,013     19,031     19,051     19,073
───────┴───────────────────────────────────────────────────────────────────────────────────────────────────────────────


 index │                                  first  50  palindromic prime cyclops numbers
───────┼───────────────────────────────────────────────────────────────────────────────────────────────────────────────
   1   │        101     16,061     31,013     35,053     38,083     73,037     74,047     91,019     94,049  1,120,211
  11   │  1,150,511  1,160,611  1,180,811  1,190,911  1,250,521  1,280,821  1,360,631  1,390,931  1,490,941  1,520,251
  21   │  1,550,551  1,580,851  1,630,361  1,640,461  1,660,661  1,670,761  1,730,371  1,820,281  1,880,881  1,930,391
  31   │  1,970,791  3,140,413  3,160,613  3,260,623  3,310,133  3,380,833  3,460,643  3,470,743  3,590,953  3,670,763
  41   │  3,680,863  3,970,793  7,190,917  7,250,527  7,310,137  7,540,457  7,630,367  7,690,967  7,750,577  7,820,287
───────┴───────────────────────────────────────────────────────────────────────────────────────────────────────────────

Wren

Library: Wren-seq
Library: Wren-fmt
Library: Wren-str

<lang ecmascript>import "/math" for Int import "/seq" for Lst import "/fmt" for Fmt import "/str" for Str

var findFirst = Fn.new { |list|

   var i = 0
   for (n in list) {
       if (n > 1e7)  return [n, i]
       i = i + 1
   }

}

var ranges = [0..0, 101..909, 11011..99099, 1110111..9990999, 111101111..119101111] var cyclops = [] for (r in ranges) {

   var numDigits = r.from.toString.count
   var center = (numDigits / 2).floor
   for (i in r) {
       var digits = Int.digits(i)
       if (digits[center] == 0 && digits.count { |d| d == 0 } == 1) cyclops.add(i)
   }

}

System.print("The first 50 cyclops numbers are:") var candidates = cyclops[0...50] var ni = findFirst.call(cyclops) for (chunk in Lst.chunks(candidates, 10)) Fmt.print("$,6d", chunk) Fmt.print("\nFirst such number > 10 million is $,d at zero-based index $,d", ni[0], ni[1])

System.print("\n\nThe first 50 prime cyclops numbers are:") var primes = cyclops.where { |n| Int.isPrime(n) } candidates = primes.take(50).toList ni = findFirst.call(primes) for (chunk in Lst.chunks(candidates, 10)) Fmt.print("$,6d", chunk) Fmt.print("\nFirst such number > 10 million is $,d at zero-based index $,d", ni[0], ni[1])

System.print("\n\nThe first 50 blind prime cyclops numbers are:") var bpcyclops = [] var ppcyclops = [] for (p in primes) {

   var ps = p.toString
   var numDigits = ps.count
   var center = (numDigits/2).floor
   var noMiddle = Num.fromString(Str.delete(ps, center))
   if (Int.isPrime(noMiddle)) bpcyclops.add(p)
   if (ps == ps[-1..0]) ppcyclops.add(p)

} candidates = bpcyclops[0...50] ni = findFirst.call(bpcyclops) for (chunk in Lst.chunks(candidates, 10)) Fmt.print("$,6d", chunk) Fmt.print("\nFirst such number > 10 million is $,d at zero-based index $,d", ni[0], ni[1])

System.print("\n\nThe first 50 palindromic prime cyclops numbers are:") candidates = ppcyclops[0...50] ni = findFirst.call(ppcyclops) for (chunk in Lst.chunks(candidates, 8)) Fmt.print("$,9d", chunk) Fmt.print("\nFirst such number > 10 million is $,d at zero-based index $,d", ni[0], ni[1])</lang>

Output:
The first 50 cyclops numbers are:
     0    101    102    103    104    105    106    107    108    109
   201    202    203    204    205    206    207    208    209    301
   302    303    304    305    306    307    308    309    401    402
   403    404    405    406    407    408    409    501    502    503
   504    505    506    507    508    509    601    602    603    604

First such number > 10 million is 111,101,111 at zero-based index 538,084


The first 50 prime cyclops numbers are:
   101    103    107    109    307    401    409    503    509    601
   607    701    709    809    907 11,027 11,047 11,057 11,059 11,069
11,071 11,083 11,087 11,093 12,011 12,037 12,041 12,043 12,049 12,071
12,073 12,097 13,033 13,037 13,043 13,049 13,063 13,093 13,099 14,011
14,029 14,033 14,051 14,057 14,071 14,081 14,083 14,087 15,013 15,017

First such number > 10 million is 111,101,129 at zero-based index 39,319


The first 50 blind prime cyclops numbers are:
   101    103    107    109    307    401    503    509    601    607
   701    709    809    907 11,071 11,087 11,093 12,037 12,049 12,097
13,099 14,029 14,033 14,051 14,071 14,081 14,083 14,087 15,031 15,053
15,083 16,057 16,063 16,067 16,069 16,097 17,021 17,033 17,041 17,047
17,053 17,077 18,047 18,061 18,077 18,089 19,013 19,031 19,051 19,073

First such number > 10 million is 111,101,161 at zero-based index 11,393


The first 50 palindromic prime cyclops numbers are:
      101    16,061    31,013    35,053    38,083    73,037    74,047    91,019
   94,049 1,120,211 1,150,511 1,160,611 1,180,811 1,190,911 1,250,521 1,280,821
1,360,631 1,390,931 1,490,941 1,520,251 1,550,551 1,580,851 1,630,361 1,640,461
1,660,661 1,670,761 1,730,371 1,820,281 1,880,881 1,930,391 1,970,791 3,140,413
3,160,613 3,260,623 3,310,133 3,380,833 3,460,643 3,470,743 3,590,953 3,670,763
3,680,863 3,970,793 7,190,917 7,250,527 7,310,137 7,540,457 7,630,367 7,690,967
7,750,577 7,820,287

First such number > 10 million is 114,808,411 at zero-based index 66