Inconsummate numbers in base 10: Difference between revisions

(Added AppleScript.)
Line 483:
99999 { incons 1000000
536081</syntaxhighlight>
=={{header|jq}}==
'''Adapted from [[#Wren|Wren]]'''
 
'''Works with jq, the C implementation of jq'''
<syntaxhighlight lang=jq>
def digitSum:
def add(s): reduce s as $_ (0; .+$_);
add(tostring | explode[] | . - 48);
 
# Maximum ratio for 6 digit numbers is 100,000
def cons:
reduce range(1; 1000000) as $i ([];
($i | digitSum) as $ds
| ($i/$ds) as $ids
| if $ids|floor == $ids then .[$ids] = true else . end);
 
def lpad($len): tostring | ($len - length) as $l | (" " * $l)[:$l] + .;
 
def task($n; $nth):
cons as $cons
| reduce range(1; $cons|length) as $i ([];
if ($cons[$i]|not) then . + [$i] else . end)
| "First \($n) inconsummate numbers in base 10:",
(.[0:50] | _nwise(10) | map(lpad(3)) | join(" ")),
"\nThe \($nth)th:",
.[$nth - 1];
 
task(50; 1000)
</syntaxhighlight>
{{output}}
<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
 
The 1000th:
6996
</pre>
 
=={{header|Pascal}}==
==={{header|Free Pascal}}===
2,442

edits