Find the composite numbers k in base 10, that have no single digit prime factors and whose prime factors are all a substring of k.



Task
 Find and show here, on this page, the first ten elements of the sequence.


Stretch
 Find and show the next ten elements.




include xpllib;         \for ItoA, StrFind and RlOutC
int  K, C;
 
proc Factor;            \Show certain K factors
int  L, N, F, Q;
char SA(10), SB(10);
[ItoA(K, SB);
L:= sqrt(K);            \limit for speed
N:= K;  F:= 3;
if (N&1) = 0 then return;               \reject if 2 is a factor
loop    [Q:= N/F;
        if rem(0) = 0 then              \found a factor, F
                [if F < 10 then return; \reject if too small (3, 5, 7)
                ItoA(F, SA);            \reject if not a sub-string
                if StrFind(SB, SA) = 0 then return;
                N:= Q;
                if F>N then quit;       \all factors found
                ]
        else    [F:= F+2;               \try next prime factor
                if F>L then
                        [if N=K then return;    \reject prime K
                        ItoA(N, SA);            \ (it's not composite)
                        if StrFind(SB, SA) = 0 then return;
                        quit;           \passed all restrictions
                        ];
                ];
        ];
Format(9, 0);
RlOutC(0, float(K));
C:= C+1;
if rem(C/10) = 0 then CrLf(0);
];
 
[C:= 0;                 \initialize element counter
K:= 11*11;              \must have at least two 2-digit composites
repeat  Factor;
        K:= K+2;        \must be odd because all factors > 2 are odd primes
until   C >= 20;
]