Composite numbers k with no single digit factors whose factors are all substrings of k

var e = Enumerator({|f|
 
    var c = (9.primorial)
    var a = (1..c -> grep { .is_coprime(c) })
 
    loop {
        var n = a.shift
 
        a.push(n + c)
        n.is_composite || next
 
        f(n) if n.factor.all {|p| Str(n).contains(p) }
    }
})
 
var count = 10
 
e.each {|n|
    say n
    break if (--count <= 0)
}

Output:

15317
59177
83731
119911
183347
192413
1819231
2111317
2237411
3129361

Last updated