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 F# 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 F# 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 F# programming language

Source code in the fsharp programming language

// Composite numbers k with no single digit factors whose factors are all substrings of k.  Nigel Galloway: January 28th., 2022
let fG n g=let rec fN i g e l=match i<g,g=0L,i%10L=g%10L with (true,_,_)->false |(_,true,_)->true |(_,_,true)->fN(i/10L)(g/10L) e l |_->fN l e e (l/10L) in fN n g g (n/10L)
let fN(g:int64)=Open.Numeric.Primes.Prime.Factors g|>Seq.skip 1|>Seq.distinct|>Seq.forall(fun n->fG g n)
Seq.unfold(fun n->Some(n|>List.filter(fun(n:int64)->not(Open.Numeric.Primes.Prime.Numbers.IsPrime &n) && fN n),n|>List.map((+)210L)))([1L..2L..209L]
|>List.filter(fun n->n%3L>0L && n%5L>0L && n%7L>0L))|>Seq.concat|>Seq.skip 1|>Seq.take 20|>Seq.iter(printfn "%d")


  

You may also check:How to resolve the algorithm 100 doors step by step in the Mercury programming language
You may also check:How to resolve the algorithm Singly-linked list/Traversal step by step in the jq programming language
You may also check:How to resolve the algorithm N-queens problem step by step in the GAP programming language
You may also check:How to resolve the algorithm Yellowstone sequence step by step in the Raku programming language
You may also check:How to resolve the algorithm Bitcoin/address validation step by step in the Go programming language