Gapful numbers: Difference between revisions

Line 1,770:
1000000016,1000000020,1000000027,1000000030,1000000032</pre>
 
=={{header|jq}}==
 
The following program works with both jq and gojq; for very large integers, the latter should be used.
 
<lang jq># emit a stream of gapful numbers greater than or equal to $start,
# which is assumed to be an integer
def gapful($start):
range($start; infinite)
| . as $i
| tostring as $s
| (($s[:1] + $s[-1:]) | tonumber) as $x
| select($i % $x == 0);
 
"First 30 gapful numbersstarting from 100:",
([limit(30;gapful(100))] | join(" ")),
"First 15 gapful numbers starting from 1,000,000:",
([limit(15;gapful(1000000))] | join(" ")),
"First 10 gapful numbers starting from 10^9:",
([limit(10;gapful(pow(10;9)))] | join(" "))</lang>
{{out}}
<pre>First 30 gapful numbers starting from 100:
100 105 108 110 120 121 130 132 135 140 143 150 154 160 165 170 176 180 187 190 192 195 198 200 220 225 231 240 242 253
First 15 gapful numbers starting from 1,000,000:
1000000 1000005 1000008 1000010 1000016 1000020 1000021 1000030 1000032 1000034 1000035 1000040 1000050 1000060 1000065
First 10 gapful numbers starting from 10^9:
1000000000 1000000001 1000000005 1000000008 1000000010 1000000016 1000000020 1000000027 1000000030 1000000032</pre>
=={{header|Julia}}==
<lang julia>using Lazy, Formatting
2,487

edits