Inconsummate numbers in base 10: Difference between revisions

Added Wren
(New draft task and Raku entry)
 
(Added Wren)
Line 50:
 
One thousandth: 6996</pre>
 
=={{header|Wren}}==
{{libheader|Wren-math}}
{{libheader|Wren-fmt}}
It appears to be more than enough to calculate ratios for all numbers up to 999,999 (which only takes about 0.4 seconds on my machine) to be sure of finding the 1,000th inconsummate number.
<syntaxhighlight lang="ecmascript">import "./math" for Int
import "./fmt" for Fmt
 
// Maximum ratio for 6 digit numbers is 100,000
var cons = List.filled(100001, false)
for (i in 1..999999) {
var ds = Int.digitSum(i)
var ids = i/ds
if (ids.isInteger) cons[ids] = true
}
var incons = []
for (i in 1...cons.count) {
if (!cons[i]) incons.add(i)
}
System.print("First 50 inconsummate numbers in base 10:")
Fmt.tprint("$3d", incons[0..49], 10)
Fmt.print("\nOne thousandth: $,d", incons[999])</syntaxhighlight>
 
{{out}}
<pre>
First 50 inconsummate numbers in base 10:
62 63 65 75 84 95 161 173 195 216
261 266 272 276 326 371 372 377 381 383
386 387 395 411 416 422 426 431 432 438
441 443 461 466 471 476 482 483 486 488
491 492 493 494 497 498 516 521 522 527
 
One thousandth: 6,996
</pre>
9,476

edits