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
 OEIS A134808 - Cyclops numbers
 OEIS A134809 - Cyclops primes
 OEIS A329737 - Cyclops primes that remain prime after being "blinded"
 OEIS A136098 - Prime palindromic cyclops numbers




func IsCyclops(N);      \Return 'true' if N is a cyclops number
int  N, I, J, K;
char A(9);
[I:= 0;                 \parse digits into array A
repeat  N:= N/10;
        A(I):= rem(0);
        I:= I+1;
until   N=0;
if (I&1) = 0 then return false; \must have odd number of digits
K:= I>>1;
if A(K) # 0 then return false;  \middle digit must be 0
for J:= 0 to I-1 do             \other digits must not be 0
        if A(J)=0 & J#K then return false;
return true;
];
 
func IsPrime(N);        \Return 'true' if N > 2 is a prime number
int  N, I;
[if (N&1) = 0 \even number\ then return false;
for I:= 3 to sqrt(N) do
    [if rem(N/I) = 0 then return false;
    I:= I+1;
    ];
return true;
];
 
func Blind(N);          \Return blinded cyclops number
int  N, I, J, K;        \i.e. center zero removed
char A(9);
[I:= 0;                 \parse digits into array A
repeat  N:= N/10;
        A(I):= rem(0);
        I:= I+1;
until   N=0;
N:= A(I-1);             \most significant digit
K:= I>>1;
for J:= I-2 downto 0 do
    if J#K then         \skip middle zero
        N:= N*10 + A(J);
return N;
];
 
func Reverse(N);        \Return N with its digits reversed
int  N, M;
[M:= 0;
repeat  N:= N/10;
        M:= M*10 + rem(0);
until   N=0;
return M;
];
 
func    IntLen(N);      \Return number of decimal digits in N
int     N;
int     P, I;
[P:= 10;
for I:= 1 to 9 do       \assumes N is 32-bits
        [if P>N then return I;
        P:= P*10;
        ];
return 10;
];
 
int Count, N;
 
func Show;              \Show results and return 'true' when done
[Count:= Count+1;
    if Count <= 50 then
        [IntOut(0, N);
        if rem(Count/10) = 0 then CrLf(0) else ChOut(0, 9\tab\);
        ];
    if N > 10_000_000 then
        [Text(0, "First such number > 10,000,000: ");
        IntOut(0, N);
        Text(0, " at zero based index: ");
        IntOut(0, Count-1);
        CrLf(0);
        return true;
        ];
return false;
];
 
proc Common(Filter);    \Common code gathered here
int  Filter;
[Count:= 0;
N:= 0;
loop    [if IsCyclops(N) then
           case Filter of
             0: if Show then quit;
             1: if IsPrime(N) then
                    if Show then quit;
             2: if IsPrime(N) then if IsPrime(Blind(N)) then
                    if Show then quit;
             3: if N=Reverse(N) then if IsPrime(N) then
                    if Show then quit
           other        [];
        N:= N+1;
        if (IntLen(N)&1) = 0 then N:= N*10;     \must have odd number of digits
        ];
];
 
[Text(0, "First 50 cyclops numbers:
");
Common(0);
Text(0, "
First 50 prime cyclops numbers:
");
Common(1);
Text(0, "
First 50 blind prime cyclops numbers:
");
Common(2);
Text(0, "
First 50 palindromic prime cyclops numbers:
");
Common(3);
]