Inconsummate numbers in base 10: Difference between revisions

m
julia example
(Added various BASIC dialects (BASIC256, Chipmunk Basic, GW-BASIC, QBasic, True Basic, QBasic, True BASIC, XBasic and Yabasic))
m (julia example)
Line 902:
6996
</pre>
 
=={{header|Julia}}==
<syntaxhighlight lang="julia">using ResumableFunctions
 
@resumable function gen_inconsummate(maxwanted)
mindigitsums = map(i -> (10^i, (10^(i-2) * 11 - 1) ÷ (9 * i - 17)), 2:14)
limit = minimum(p[1] for p in mindigitsums if p[2] > maxwanted)
arr = zeros(Int, limit)
arr[1] = 1
for dividend in 1:limit-1
dsum = sum(digits(dividend))
quo, rem = divrem(dividend, dsum)
rem == 0 && quo < limit && (arr[quo] = 1)
end
for j in eachindex(arr)
arr[j] == 0 && @yield(j)
end
end
 
println("The first 50 inconsummate numbers in base 10:")
for (i, j) in enumerate(gen_inconsummate(100000))
if i <= 50
print(rpad(j, 6), i % 10 == 0 ? "\n" : "")
elseif i == 1000
println("\nThe one-thousandth inconsummate number in base 10 is $j")
elseif i == 10000
println("The ten-thousandth inconsummate number in base 10 is $j")
elseif i == 100000
println("The hundred-thousandth inconsummate number in base 10 is $j")
break
end
end
</syntaxhighlight>{{out}}
<pre>
The 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 one-thousandth inconsummate number in base 10 is 6996
The ten-thousandth inconsummate number in base 10 is 59853
The hundred-thousandth inconsummate number in base 10 is 536081
</pre>
 
 
=={{header|Nim}}==
4,105

edits