How to resolve the algorithm Composite numbers k with no single digit factors whose factors are all substrings of k step by step in the Sidef programming language

Published on 12 May 2024 09:40 PM

How to resolve the algorithm Composite numbers k with no single digit factors whose factors are all substrings of k step by step in the Sidef programming language

Table of Contents

Problem Statement

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.

Let's start with the solution:

Step by Step solution about How to resolve the algorithm Composite numbers k with no single digit factors whose factors are all substrings of k step by step in the Sidef programming language

Source code in the sidef programming language

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)
}


  

You may also check:How to resolve the algorithm Maximum triangle path sum step by step in the Erlang programming language
You may also check:How to resolve the algorithm Goldbach's comet step by step in the Python programming language
You may also check:How to resolve the algorithm Sort a list of object identifiers step by step in the Wren programming language
You may also check:How to resolve the algorithm Hello world/Text step by step in the உயிர்/Uyir programming language
You may also check:How to resolve the algorithm Repeat a string step by step in the AWK programming language