Gapful numbers

From Rosetta Code
Task
Gapful numbers
You are encouraged to solve this task according to the task description, using any language you may know.

Numbers   (positive integers expressed in base ten)   that are (evenly) divisible by the number formed by the first and last digit are known as   gapful numbers.

All   one─   and two─digit   numbers have this property and are trivially excluded.   Only numbers   100   will be considered for this Rosetta Code task.


Example

187   is a   gapful   number because it is evenly divisible by the number   17   which is formed by the first and last decimal digits of   187.


About 7.46% of positive integers are gapful.


Task
  •   Generate and show all sets of numbers (below) on one line (horizontally) with a title,   here on this page
  •   Show the first   30   gapful numbers
  •   Show the first   15   gapful numbers           1,000,000
  •   Show the first   10   gapful numbers     1,000,000,000


Related task


Also see



C[edit]

 
#include<stdio.h>
 
void generateGaps(unsigned long long int start,int count){
 
int counter = 0;
unsigned long long int i = start;
char str[100];
 
printf("\nFirst %d Gapful numbers >= %llu :\n",count,start);
 
while(counter<count){
sprintf(str,"%llu",i);
if((i%(10*(str[0]-'0') + i%10))==0L){
printf("\n%3d : %llu",counter+1,i);
counter++;
}
i++;
}
}
 
int main()
{
unsigned long long int i = 100;
int count = 0;
char str[21];
 
generateGaps(100,30);
printf("\n");
generateGaps(1000000,15);
printf("\n");
generateGaps(1000000000,15);
printf("\n");
 
return 0;
}
 

Output :

[email protected]:~/doodles$ ./a.out

First 30 Gapful numbers >= 100 :

  1 : 100
  2 : 105
  3 : 108
  4 : 110
  5 : 120
  6 : 121
  7 : 130
  8 : 132
  9 : 135
 10 : 140
 11 : 143
 12 : 150
 13 : 154
 14 : 160
 15 : 165
 16 : 170
 17 : 176
 18 : 180
 19 : 187
 20 : 190
 21 : 192
 22 : 195
 23 : 198
 24 : 200
 25 : 220
 26 : 225
 27 : 231
 28 : 240
 29 : 242
 30 : 253

First 15 Gapful numbers >= 1000000 :

  1 : 1000000
  2 : 1000005
  3 : 1000008
  4 : 1000010
  5 : 1000016
  6 : 1000020
  7 : 1000021
  8 : 1000030
  9 : 1000032
 10 : 1000034
 11 : 1000035
 12 : 1000040
 13 : 1000050
 14 : 1000060
 15 : 1000065

First 15 Gapful numbers >= 1000000000 :

  1 : 1000000000
  2 : 1000000001
  3 : 1000000005
  4 : 1000000008
  5 : 1000000010
  6 : 1000000016
  7 : 1000000020
  8 : 1000000027
  9 : 1000000030
 10 : 1000000032
 11 : 1000000035
 12 : 1000000039
 13 : 1000000040
 14 : 1000000050
 15 : 1000000053

Factor[edit]

USING: formatting kernel lists lists.lazy math math.functions
math.text.utils sequences ;
 
: gapful? ( n -- ? )
dup 1 digit-groups [ first ] [ last 10 * + ] bi divisor? ;
 
30 100 15 1,000,000 10 1,000,000,000 [
2dup lfrom [ gapful? ] lfilter ltake list>array
"%d gapful numbers starting at %d:\n%[%d, %]\n\n" printf
] [email protected]
Output:
30 gapful numbers starting at 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 }

15 gapful numbers starting at 1000000:
{ 1000000, 1000005, 1000008, 1000010, 1000016, 1000020, 1000021, 1000030, 1000032, 1000034, 1000035, 1000040, 1000050, 1000060, 1000065 }

10 gapful numbers starting at 1000000000:
{ 1000000000, 1000000001, 1000000005, 1000000008, 1000000010, 1000000016, 1000000020, 1000000027, 1000000030, 1000000032 }

Fōrmulæ[edit]

In this page you can see the solution of this task.

Fōrmulæ programs are not textual, visualization/edition of programs is done showing/manipulating structures but not text (more info). Moreover, there can be multiple visual representations of the same program. Even though it is possible to have textual representation —i.e. XML, JSON— they are intended for transportation effects more than visualization and edition.

The option to show Fōrmulæ programs and their results is showing images. Unfortunately images cannot be uploaded in Rosetta Code.

Go[edit]

package main
 
import "fmt"
 
func commatize(n uint64) string {
s := fmt.Sprintf("%d", n)
le := len(s)
for i := le - 3; i >= 1; i -= 3 {
s = s[0:i] + "," + s[i:]
}
return s
}
 
func main() {
starts := []uint64{1e2, 1e6, 1e7, 1e9, 7123}
counts := []int{30, 15, 15, 10, 25}
for i := 0; i < len(starts); i++ {
count := 0
j := starts[i]
pow := uint64(100)
for {
if j < pow*10 {
break
}
pow *= 10
}
fmt.Printf("First %d gapful numbers starting at %s:\n", counts[i], commatize(starts[i]))
for count < counts[i] {
fl := (j/pow)*10 + (j % 10)
if j%fl == 0 {
fmt.Printf("%d ", j)
count++
}
j++
if j >= 10*pow {
pow *= 10
}
}
fmt.Println("\n")
}
}
Output:
First 30 gapful numbers starting at 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 at 1,000,000:
1000000 1000005 1000008 1000010 1000016 1000020 1000021 1000030 1000032 1000034 1000035 1000040 1000050 1000060 1000065 

First 15 gapful numbers starting at 10,000,000:
10000000 10000001 10000003 10000004 10000005 10000008 10000010 10000016 10000020 10000030 10000032 10000035 10000040 10000050 10000060 

First 10 gapful numbers starting at 1,000,000,000:
1000000000 1000000001 1000000005 1000000008 1000000010 1000000016 1000000020 1000000027 1000000030 1000000032 

First 25 gapful numbers starting at 7,123:
7125 7140 7171 7189 7210 7272 7275 7280 7296 7350 7373 7420 7425 7474 7488 7490 7560 7575 7630 7632 7676 7700 7725 7770 7777 

Julia[edit]

using Lazy, Formatting
 
firstlast(a) = 10 * a[end] + a[1]
isgapful(n) = (d = digits(n); length(d) < 3 || (m = firstlast(d)) != 0 && mod(n, m) == 0)
gapfuls(start) = filter(isgapful, Lazy.range(start))
 
for (x, n) in [(100, 30), (1_000_000, 15), (1_000_000_000, 10)]
println("First $n gapful numbers starting at ", format(x, commas=true), ":\n",
take(n, gapfuls(x)))
end
 
Output:
First 30 gapful numbers starting at 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 at 1,000,000:
(1000000 1000005 1000008 1000010 1000016 1000020 1000021 1000030 1000032 1000034 1000035 1000040 1000050 1000060 1000065)
First 10 gapful numbers starting at 1,000,000,000:
(1000000000 1000000001 1000000005 1000000008 1000000010 1000000016 1000000020 1000000027 1000000030 1000000032)

Pascal[edit]

Translation of: Go
Works with: Free Pascal
Works with: Delphi

Now using using en passant updated MOD-values. Only recognizable for huge amounts of tests 100|74623687 ( up to 1 billion )-> takes 1.845s instead of 11.25s

program gapful;
{$IFDEF FPC}
{$MODE DELPHI}{$OPTIMIZATION ON,ALL}
{$ELSE}
{$APPTYPE CONSOLE}
{$ENDIF}
 
uses
sysutils,// IntToStr
strUtils;// Numb2USA aka commatize
const
cIdx = 5;
starts : array [0..cIdx-1] of Uint64
= (100,1000*1000, 10*1000*1000,1000*1000*1000, 7123);
counts : array [0..cIdx-1] of Uint64 = (30, 15,15, 10, 25);
//100| 74623687 => 1000*1000*1000
//100| 746236131 => 10*1000*1000*1000
//100|7462360431 =>100*1000*1000*1000
Base = 10;
var
ModsHL : array[0..99] of NativeUint;
Pow10 : Uint64; //global, seldom used
countLmt : NativeUint;//Uint64; only for extreme counting
 
procedure OutHeader(i: NativeInt);
Begin
writeln('First ',counts[i],', gapful numbers starting at ',
Numb2USA(IntToStr(starts[i])));
end;
 
procedure OutNum(n:Uint64);
Begin
write(' ',n);
end;
 
procedure InitMods(n:Uint64;H_dgt:NativeUint);
//calculate first mod of n, when it reaches n
var
i,j : NativeInt;
Begin
j := H_dgt; //= H_dgt+i
For i := 0 to Base-1 do
Begin
ModsHL[j] := n MOD j;
inc(n);
inc(j);
end;
end;
 
procedure InitMods2(n:Uint64;H_dgt,L_Dgt:NativeUint);
//calculate first mod of n, when it reaches n
//beware, that the lower n are reached in the next base round
var
i,j : NativeInt;
Begin
j := H_dgt;
n := n-L_Dgt;
For i := 0 to L_Dgt-1 do
Begin
ModsHL[j] := (n+base) MOD j;
inc(n);
inc(j);
end;
For i := L_Dgt to Base-1 do
Begin
ModsHL[j] := n MOD j;
inc(n);
inc(j);
end;
end;
 
procedure Main(TestNum:Uint64;Cnt:NativeUint);
var
LmtNextNewHiDgt: Uint64;
tmp,LowDgt,GapNum : NativeUint;
Begin
countLmt := cnt;
Pow10 := Base*Base;
LmtNextNewHiDgt := Base*Pow10;
while LmtNextNewHiDgt <= TestNum do
Begin
Pow10 := LmtNextNewHiDgt;
LmtNextNewHiDgt *= Base;
end;
LowDgt := TestNum MOD Base;
GapNum := TestNum DIV Pow10;
LmtNextNewHiDgt := (GapNum+1)*Pow10;
GapNum := Base*GapNum;
IF LowDgt <> 0 then
InitMods2(TestNum,GapNum,LowDgt)
else
InitMODS(TestNum,GapNum);
 
GapNum += LowDgt;
repeat
// if TestNum MOD (GapNum) = 0 then
if ModsHL[GapNum]=0 then
Begin
tmp := countLmt-1;
IF tmp < 32 then
OutNum(TestNum);
countLmt := tmp;
// Test and BREAK only if something has changed
IF tmp = 0 then
BREAK;
end;
tmp := Base + ModsHL[GapNum];
//translate into "if-less" version 3.35s -> 1.85s
//bad branch prediction :-(
//if tmp >= GapNum then tmp -= GapNum;
tmp -= (-ORD(tmp >=GapNum) AND GapNum);
ModsHL[GapNum]:= tmp;
 
TestNum += 1;
tmp := LowDgt+1;
GapNum+=1;
IF tmp >= Base then
Begin
tmp := 0;
GapNum -= Base;
end;
LowDgt := tmp;
//next Hi Digit
if TestNum >= LmtNextNewHiDgt then
Begin
LowDgt := 0;
GapNum +=Base;
LmtNextNewHiDgt += Pow10;
//next power of 10
if GapNum >= Base*Base then
Begin
Pow10 *= Base;
LmtNextNewHiDgt := 2*Pow10;
GapNum := Base;
end;
initMods(TestNum,GapNum);
end;
until false;
end;
 
var
i : integer;
Begin
for i := 0 to High(starts) do
Begin
OutHeader(i);
Main(starts[i],counts[i]);
writeln(#13#10);
end;
end.
Output:
First 30, gapful numbers starting at 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 at 1,000,000
 1000000 1000005 1000008 1000010 1000016 1000020 1000021 1000030 1000032 1000034 1000035 1000040 1000050 1000060 1000065

First 15, gapful numbers starting at 10,000,000
 10000000 10000001 10000003 10000004 10000005 10000008 10000010 10000016 10000020 10000030 10000032 10000035 10000040 10000050 10000060

First 10, gapful numbers starting at 1,000,000,000
 1000000000 1000000001 1000000005 1000000008 1000000010 1000000016 1000000020 1000000027 1000000030 1000000032

First 25, gapful numbers starting at 7,123
 7125 7140 7171 7189 7210 7272 7275 7280 7296 7350 7373 7420 7425 7474 7488 7490 7560 7575 7630 7632 7676 7700 7725 7770 7777
_____
First 74623687, gapful numbers starting at 100
 999998976 999999000 999999090 999999091 999999099 999999152 999999165 999999180 999999270 999999287 999999333 999999354 999999355 999999360 999999448 999999450 999999456 999999540 999999545 999999612 999999630 999999720 999999735 999999810 999999824 999999900 999999925 999999936 999999938 999999990 1000000000

real    0m1,845s
start  |    count
  //100|  74623687  =>    1000*1000*1000
  //100| 746236131  => 10*1000*1000*1000
  //100|7462360431  =>100*1000*1000*1000 

only counting[edit]

program gapful;
{$IFDEF FPC}
{$MODE DELPHI}{$OPTIMIZATION ON,ALL}
{$ELSE}
{$APPTYPE CONSOLE}
{$ENDIF}
uses
sysutils,// IntToStr
strUtils;// Numb2USA aka commatize
 
var
LCMsHL : array of NativeInt;
 
function GCD(a, b: Int64): Int64;
var
temp: Int64;
begin
while b <> 0 do
begin
temp := b;
b := a mod b;
a := temp
end;
result := a
end;
 
function LCM(a, b: Int64): Int64;
begin
LCM := (a DIV GCD(a,b)) * b;
end;
 
procedure InitLCM(Base:NativeInt);
var
i : integer;
Begin
For i := Base to (Base*Base-1) do
LCMsHL[i] := LCM(i,Base);
end;
 
function CountGapFul(H_Digit,Base:NativeInt;PotBase:Uint64):Uint64;
//Counts gapfulnumbers [n*PotBase..(n+1)*PotBase -1] ala [100..199]
var
EndDgt,Dgt : NativeInt;
P,k,lmt,sum,dSum: UInt64;
begin
P := PotBase*H_Digit;
lmt := P+PotBase-1;
Dgt := H_Digit*Base;
sum := (PotBase-1) DIV dgt +1;
For EndDgt := 1 to Base-1 do
Begin
inc(Dgt);
//search start
//first value divisible by dgt
k := p-(p MOD dgt)+ dgt;
//value divisible by dgt ending in the right digit
while (k mod Base) <> EndDgt do
inc(k,dgt);
IF k> lmt then
continue;
//one found +1
//count the occurences in (lmt-k)
dSum := (lmt-k) DIV LCMsHL[dgt] +1;
inc(sum,dSum);
//writeln(dgt:5,k:21,dSum:21,Sum:21);
end;
//writeln(p:21,Sum:21);
CountGapFul := sum;
end;
 
procedure Main(Base:NativeUInt);
var
i : NativeUInt;
pot,total,lmt: Uint64;//High(Uint64) = 2^64-1
Begin
lmt := High(pot) DIV Base;
pot := sqr(Base);//"100" in Base
setlength(LCMsHL,pot);
InitLCM(Base);
total := 0;
repeat
IF pot > lmt then
break;
For i := 1 to Base-1 do //ala 100..199 ,200..299,300..399,..,900..999
inc(total,CountGapFul(i,base,pot));
pot *= Base;
writeln('Total [',sqr(Base),'..',Numb2USA(IntToStr(pot)),'] : ',Numb2USA(IntToStr(total+1)));
until false;
setlength(LCMsHL,0);
end;
 
BEGIN
Main(10);
Main(100);
END.
Output:
Base :10
Total [100..1,000] : 77
Total [100..10,000] : 765
Total [100..100,000] : 7,491
Total [100..1,000,000] : 74,665
Total [100..10,000,000] : 746,286
Total [100..100,000,000] : 7,462,438
Total [100..1,000,000,000] : 74,623,687
Total [100..10,000,000,000] : 746,236,131
Total [100..100,000,000,000] : 7,462,360,431
Total [100..1,000,000,000,000] : 74,623,603,381
Total [100..10,000,000,000,000] : 746,236,032,734
Total [100..100,000,000,000,000] : 7,462,360,326,234
Total [100..1,000,000,000,000,000] : 74,623,603,260,964
Total [100..10,000,000,000,000,000] : 746,236,032,608,141
Total [100..100,000,000,000,000,000] : 7,462,360,326,079,810
Total [100..1,000,000,000,000,000,000] : 74,623,603,260,796,424
Total [100..10,000,000,000,000,000,000] : 746,236,032,607,962,357

Base :100
Total [10000..1,000,000] : 6,039
Total [10000..100,000,000] : 251,482
Total [10000..10,000,000,000] : 24,738,934
Total [10000..1,000,000,000,000] : 2,473,436,586
Total [10000..100,000,000,000,000] : 247,343,160,115
Total [10000..10,000,000,000,000,000] : 24,734,315,489,649
Total [10000..1,000,000,000,000,000,000] : 2,473,431,548,401,507

Perl[edit]

use strict;
use warnings;
use feature 'say';
 
sub comma { reverse ((reverse shift) =~ s/(.{3})/$1,/gr) =~ s/^,//r }
 
sub is_gapful { my $n = shift; 0 == $n % join('', (split //, $n)[0,-1]) }
 
use constant Inf => 1e10;
for ([1e2, 30], [1e6, 15], [1e9, 10], [7123, 25]) {
my($start, $count) = @$_;
printf "\nFirst $count gapful numbers starting at %s:\n", comma $start;
my $n = 0; my $g = '';
$g .= do { $n < $count ? (is_gapful($_) and ++$n and "$_ ") : last } for $start .. Inf;
say $g;
}
Output:
First 30 gapful numbers starting at 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 at 1,000,000:
1000000 1000005 1000008 1000010 1000016 1000020 1000021 1000030 1000032 1000034 1000035 1000040 1000050 1000060 1000065

First 10 gapful numbers starting at 1,000,000,000:
1000000000 1000000001 1000000005 1000000008 1000000010 1000000016 1000000020 1000000027 1000000030 1000000032

First 25 gapful numbers starting at 7,123:
7125 7140 7171 7189 7210 7272 7275 7280 7296 7350 7373 7420 7425 7474 7488 7490 7560 7575 7630 7632 7676 7700 7725 7770 7777

Perl 6[edit]

Works with: Rakudo version 2019.07.1

Also test starting on a number that doesn't start with 1. Required to have titles, may as well make 'em noble. :-)

use Lingua::EN::Numbers;
 
for (1e2, 30, 1e6, 15, 1e9, 10, 7123, 25)».Int -> $start, $count {
put "\nFirst $count gapful numbers starting at {comma $start}:\n" ~
<Sir Lord Duke King>.pick ~ ": ", ~
($start..*).grep( { $_ %% .comb[0, *-1].join } )[^$count];
}
Output:
First 30 gapful numbers starting at 100:
Sir: 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 at 1,000,000:
Duke: 1000000 1000005 1000008 1000010 1000016 1000020 1000021 1000030 1000032 1000034 1000035 1000040 1000050 1000060 1000065

First 10 gapful numbers starting at 1,000,000,000:
King: 1000000000 1000000001 1000000005 1000000008 1000000010 1000000016 1000000020 1000000027 1000000030 1000000032

First 25 gapful numbers starting at 7,123:
King: 7125 7140 7171 7189 7210 7272 7275 7280 7296 7350 7373 7420 7425 7474 7488 7490 7560 7575 7630 7632 7676 7700 7725 7770 7777

Phix[edit]

Translation of: Go
constant starts = {1e2, 1e6, 1e7, 1e9, 7123},
counts = {30, 15, 15, 10, 25}
for i=1 to length(starts) do
integer count = counts[i],
j = starts[i],
pow = 100
while j>=pow*10 do pow *= 10 end while
printf(1,"First %d gapful numbers starting at %,d: ", {count, j})
while count do
integer fl = floor(j/pow)*10 + remainder(j,10)
if remainder(j,fl)==0 then
printf(1,"%d ", j)
count -= 1
end if
j += 1
if j>=10*pow then
pow *= 10
end if
end while
printf(1,"\n")
end for
Output:
First 30 gapful numbers starting at 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 at 1,000,000: 1000000 1000005 1000008 1000010 1000016 1000020 1000021 1000030 1000032 1000034 1000035 1000040 1000050 1000060 1000065
First 15 gapful numbers starting at 10,000,000: 10000000 10000001 10000003 10000004 10000005 10000008 10000010 10000016 10000020 10000030 10000032 10000035 10000040 10000050 10000060
First 10 gapful numbers starting at 1,000,000,000: 1000000000 1000000001 1000000005 1000000008 1000000010 1000000016 1000000020 1000000027 1000000030 1000000032
First 25 gapful numbers starting at 7,123: 7125 7140 7171 7189 7210 7272 7275 7280 7296 7350 7373 7420 7425 7474 7488 7490 7560 7575 7630 7632 7676 7700 7725 7770 7777

Python[edit]

from itertools import islice, count
for start, n in [(100, 30), (1_000_000, 15), (1_000_000_000, 10)]:
print(f"\nFirst {n} gapful numbers from {start:_}")
print(list(islice(( x for x in count(start)
if (x % (int(str(x)[0]) * 10 + (x % 10)) == 0) )
, n)))
Output:
First 30 gapful numbers 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 from 1_000_000
[1000000, 1000005, 1000008, 1000010, 1000016, 1000020, 1000021, 1000030, 1000032, 1000034, 1000035, 1000040, 1000050, 1000060, 1000065]

First 10 gapful numbers from 1_000_000_000
[1000000000, 1000000001, 1000000005, 1000000008, 1000000010, 1000000016, 1000000020, 1000000027, 1000000030, 1000000032]

REXX[edit]

/*REXX program computes and displays gapful numbers and also palindromic gapful numbers.*/
numeric digits 20 /*ensure enough decimal digits gapfuls.*/
parse arg gapfuls /*obtain optional arguments from the CL*/
if gapfuls='' then gapfuls= 30 25@7123 15@1000000 10@1000000000 /*assume defaults. */
 
do until gapfuls=''; parse var gapfuls stuff gapfuls; call gapful stuff
end /*until*/
exit /*stick a fork in it, we're all done. */
/*──────────────────────────────────────────────────────────────────────────────────────*/
gapful: procedure; parse arg n '@' sp; #= 0; if sp=='' then sp= 100
say center(' 'n " gapful numbers starting at: " sp' ', 125, "═")
$= /*initialize $ list.*/
do j=sp until #==n /*SP: start point. */
parse var j a 2 '' -1 b /*get 1st & last dig*/
if j // (a||b) \== 0 then iterate /*perform ÷ into J.*/
#= # + 1; $= $ j /*bump #; append──►$*/
end /*j*/
say strip($); say; return
output   when using the default inputs:

(Shown at   5/6   size.)

═══════════════════════════════════════════ 30  gapful numbers starting at:  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

═══════════════════════════════════════════ 25  gapful numbers starting at:  7123 ═══════════════════════════════════════════
7125 7140 7171 7189 7210 7272 7275 7280 7296 7350 7373 7420 7425 7474 7488 7490 7560 7575 7630 7632 7676 7700 7725 7770 7777

═════════════════════════════════════════ 15  gapful numbers starting at:  1000000 ══════════════════════════════════════════
1000000 1000005 1000008 1000010 1000016 1000020 1000021 1000030 1000032 1000034 1000035 1000040 1000050 1000060 1000065

════════════════════════════════════════ 10  gapful numbers starting at:  1000000000 ════════════════════════════════════════
1000000000 1000000001 1000000005 1000000008 1000000010 1000000016 1000000020 1000000027 1000000030 1000000032

zkl[edit]

fcn gapfulW(start){	//--> iterator
[start..].tweak(
fcn(n){ if(n % (10*n.toString()[0] + n%10)) Void.Skip else n })
}
foreach n,z in 
( T( T(100, 30), T(1_000_000, 15), T(1_000_000_000, 10), T(7_123,25) )){
println("First %d gapful numbers starting at %,d:".fmt(z,n));
gapfulW(n).walk(z).concat(", ").println("\n");
}
Output:
First 30 gapful numbers starting at 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 at 1,000,000:
1000000, 1000005, 1000008, 1000010, 1000016, 1000020, 1000021, 1000030, 1000032, 1000034, 1000035, 1000040, 1000050, 1000060, 1000065

First 10 gapful numbers starting at 1,000,000,000:
1000000000, 1000000001, 1000000005, 1000000008, 1000000010, 1000000016, 1000000020, 1000000027, 1000000030, 1000000032

First 25 gapful numbers starting at 7,123:
7125, 7140, 7171, 7189, 7210, 7272, 7275, 7280, 7296, 7350, 7373, 7420, 7425, 7474, 7488, 7490, 7560, 7575, 7630, 7632, 7676, 7700, 7725, 7770, 7777