Composite numbers k with no single digit factors whose factors are all substrings of k: Difference between revisions
Content added Content deleted
Thundergnat (talk | contribs) (New draft task and Raku example) |
(Added Wren) |
||
Line 30: | Line 30: | ||
<pre> 15,317 59,177 83,731 119,911 183,347 192,413 1,819,231 2,111,317 2,237,411 3,129,361 |
<pre> 15,317 59,177 83,731 119,911 183,347 192,413 1,819,231 2,111,317 2,237,411 3,129,361 |
||
5,526,173 11,610,313 13,436,683 13,731,373 13,737,841 13,831,103 15,813,251 17,692,313 19,173,071 28,118,827</pre> |
5,526,173 11,610,313 13,436,683 13,731,373 13,737,841 13,831,103 15,813,251 17,692,313 19,173,071 28,118,827</pre> |
||
=={{header|Wren}}== |
|||
{{libheader|Wren-math}} |
|||
<lang ecmascript>import "/math" for Int |
|||
import "/fmt" for Fmt |
|||
var count = 0 |
|||
var k = 11 |
|||
var res = [] |
|||
while (count < 20) { |
|||
if (k % 3 == 0 || k % 5 == 0 || k % 7 == 0) { |
|||
k = k + 2 |
|||
continue |
|||
} |
|||
var factors = Int.primeFactors(k) |
|||
if (factors.count > 1) { |
|||
var s = k.toString |
|||
var includesAll = true |
|||
for (f in factors) { |
|||
if (s.indexOf(f.toString) == -1) { |
|||
includesAll = false |
|||
break |
|||
} |
|||
} |
|||
if (includesAll) { |
|||
res.add(k) |
|||
count = count + 1 |
|||
} |
|||
} |
|||
k = k + 2 |
|||
} |
|||
Fmt.print("$,10d", res[0..9]) |
|||
Fmt.print("$,10d", res[10..19])</lang> |
|||
{{out}} |
|||
<pre> |
|||
15,317 59,177 83,731 119,911 183,347 192,413 1,819,231 2,111,317 2,237,411 3,129,361 |
|||
5,526,173 11,610,313 13,436,683 13,731,373 13,737,841 13,831,103 15,813,251 17,692,313 19,173,071 28,118,827 |
|||
</pre> |
Revision as of 19:45, 19 January 2022
Composite numbers k with no single digit factors whose factors are all substrings of k is a draft programming task. It is not yet considered ready to be promoted as a complete task, for reasons that should be found in its talk page.
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.
Raku
<lang perl6>use Prime::Factor; use Lingua::EN::Numbers;
put (2..∞).hyper(:5000batch).map( {
next if (1 < $_ gcd 210) || .is-prime || any .&prime-factors.map: -> $n { !.contains: $n }; $_
} )[^20].batch(10)».&comma».fmt("%10s").join: "\n";</lang>
- Output:
15,317 59,177 83,731 119,911 183,347 192,413 1,819,231 2,111,317 2,237,411 3,129,361 5,526,173 11,610,313 13,436,683 13,731,373 13,737,841 13,831,103 15,813,251 17,692,313 19,173,071 28,118,827
Wren
<lang ecmascript>import "/math" for Int import "/fmt" for Fmt
var count = 0 var k = 11 var res = [] while (count < 20) {
if (k % 3 == 0 || k % 5 == 0 || k % 7 == 0) { k = k + 2 continue } var factors = Int.primeFactors(k) if (factors.count > 1) { var s = k.toString var includesAll = true for (f in factors) { if (s.indexOf(f.toString) == -1) { includesAll = false break } } if (includesAll) { res.add(k) count = count + 1 } } k = k + 2
} Fmt.print("$,10d", res[0..9]) Fmt.print("$,10d", res[10..19])</lang>
- Output:
15,317 59,177 83,731 119,911 183,347 192,413 1,819,231 2,111,317 2,237,411 3,129,361 5,526,173 11,610,313 13,436,683 13,731,373 13,737,841 13,831,103 15,813,251 17,692,313 19,173,071 28,118,827