Humble numbers: Difference between revisions

Line 3,055:
9 -> 1767
10 -> 2381</pre>
 
=={{header|jq}}==
 
Brute force ...
<lang>
# Input: a positive integer
# Output: true iff the input is humbler
def humble:
. as $i
| if ($i < 2) then true
elif ($i % 2 == 0) then ($i / 2 | floor) | humble
elif ($i % 3 == 0) then ($i / 3 | floor) | humble
elif ($i % 5 == 0) then ($i / 5 | floor) | humble
elif ($i % 7 == 0) then ($i / 7 | floor) | humble
else false
end;
 
def humbles:
range(1;infinite) | select(humble);
def task($digits; $count):
last(
label $out
| foreach humbles as $i ({};
($i | tostring | length) as $len
| if $len > $digits then break $out
else .humble[$len] += 1
end
| if .count < $count then .count += 1 | .humbles += [$i] else . end; . ) )
| "First \($count):", .humbles,
"Distribution of the number of decimal digits up to \($digits) digits:",
(.humble | range(1;length) as $i | " \($i): \(.[$i])");
 
task(6;50)
</lang>
{{out}}
<pre>
First 50:
[1,2,3,4,5,6,7,8,9,10,12,14,15,16,18,20,21,24,25,27,28,30,32,35,36,40,42,45,48,49,50,54,56,60,63,64,70,72,75,80,81,84,90,96,98,100,105,108,112,120]
Distribution of the number of decimal digits up to 6 digits:
1: 9
2: 36
3: 95
4: 197
5: 356
6: 579</pre>
 
 
=={{header|Julia}}==
2,462

edits