Palindromic gapful numbers

From Rosetta Code


Palindromic gapful numbers is a draft programming task. It is not yet considered ready to be promoted as a complete task, for reasons that should be found in its talk page.

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

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


A palindromic number is   (for this task, a positive integer expressed in base ten),   when the number is reversed,   is the same as the original number.


Task
  •   Show   (nine sets)   the first   20   palindromic gapful numbers that   end   with:
  •   the digit   1
  •   the digit   2
  •   the digit   3
  •   ···   ···
  •   the digit   9
  •   Show   (nine sets, like above)   of palindromic gapful numbers:
  •   the last   15   palindromic gapful numbers   (out of       100)
  •   the last   10   palindromic gapful numbers   (out of   1,000)       {optional}


(For other ways of expressing the (above) requirements, see the   discussion   page.


Related tasks


Also see



Factor[edit]

USING: formatting fry io kernel lists lists.lazy locals math
math.functions math.ranges math.text.utils prettyprint sequences ;
IN: rosetta-code.palindromic-gapful-numbers
 
! Palindromic numbers are relatively rare compared to gapful
! numbers, so our strategy for finding palindromic gapful
! numbers is to filter gapful numbers from palindromic numbers.
 
! Palindromic numbers can be generated directly rather than
! filtered or identified from the natural numbers. This is a
! significant speedup since palindromic numbers are relatively
! rare in the natural numbers.
 
! Here I have used a generation method similar to
! https://www.geeksforgeeks.org/generate-palindromic-numbers-less-n/
 
! Create a palindrome from its base natural number.
! e.g. 321 t -> 32123
! 321 f -> 321123
: create-palindrome ( n odd? -- m )
dupd [ 10 /i ] when swap [ over 0 > ]
[ 10 * [ 10 /mod ] [ + ] bi* ] while nip ;
 
! Create an infinite lazy list of palindromic numbers starting
! at 100.
: palindromes ( -- l )
1 lfrom [
10 swap ^ dup 10 * [a,b)
[ [ t create-palindrome ] map ]
[ [ f create-palindrome ] map ] bi
[ sequence>list ] [email protected] lappend
] lmap-lazy lconcat ;
 
! Is an integer gapful?
: gapful? ( n -- ? )
dup 1 digit-groups [ first ] [ last 10 * + ] bi divisor? ;
 
! Create an infinite lazy list of gapful palindromes.
: gapful-palindromes ( -- l ) palindromes [ gapful? ] lfilter ;
 
:: show-palindromic-gapfuls ( last of -- )
gapful-palindromes :> nums
last of
"~~==[ Last  %d of  %d palindromic gapful numbers starting at 100 ]==~~\n"
printf 9 [1,b] [| d |
of nums [ 10 mod d = ] lfilter ltake list>array
last tail* d pprint ": " write [ pprint bl ] each nl
] each nl ;
 
20 20  ! part 1
15 100  ! part 2
10 1000  ! part 3 (Optional)
[ show-palindromic-gapfuls ] [email protected]
Output:
~~==[ Last  20  of  20  palindromic gapful numbers starting at 100 ]==~~
1: 121 1001 1111 1221 1331 1441 1551 1661 1771 1881 1991 10901 11011 12221 13431 14641 15851 17171 18381 19591 
2: 242 2002 2112 2222 2332 2442 2552 2662 2772 2882 2992 20702 21912 22022 23232 24442 25652 26862 28182 29392 
3: 363 3003 3333 3663 3993 31713 33033 36663 300003 303303 306603 309903 312213 315513 318813 321123 324423 327723 330033 333333 
4: 484 4004 4224 4444 4664 4884 40304 42724 44044 46464 48884 400004 401104 402204 403304 404404 405504 406604 407704 408804 
5: 5005 5115 5225 5335 5445 5555 5665 5775 5885 5995 50105 51315 52525 53735 54945 55055 56265 57475 58685 59895 
6: 6006 6336 6666 6996 61116 64746 66066 69696 600006 603306 606606 609906 612216 615516 618816 621126 624426 627726 630036 633336 
7: 7007 7777 77077 700007 707707 710017 717717 720027 727727 730037 737737 740047 747747 750057 757757 760067 767767 770077 777777 780087 
8: 8008 8448 8888 80608 86768 88088 800008 802208 804408 806608 808808 821128 823328 825528 827728 829928 840048 842248 844448 846648 
9: 9009 9999 94149 99099 900009 909909 918819 927729 936639 945549 954459 963369 972279 981189 990099 999999 9459549 9508059 9557559 9606069 

~~==[ Last  15  of  100  palindromic gapful numbers starting at 100 ]==~~
1: 165561 166661 167761 168861 169961 170071 171171 172271 173371 174471 175571 176671 177771 178871 179971 
2: 265562 266662 267762 268862 269962 270072 271172 272272 273372 274472 275572 276672 277772 278872 279972 
3: 30366303 30399303 30422403 30455403 30488403 30511503 30544503 30577503 30600603 30633603 30666603 30699603 30722703 30755703 30788703 
4: 4473744 4485844 4497944 4607064 4619164 4620264 4632364 4644464 4656564 4668664 4681864 4693964 4803084 4815184 4827284 
5: 565565 566665 567765 568865 569965 570075 571175 572275 573375 574475 575575 576675 577775 578875 579975 
6: 60399306 60422406 60455406 60488406 60511506 60544506 60577506 60600606 60633606 60666606 60699606 60722706 60755706 60788706 60811806 
7: 72299227 72322327 72399327 72422427 72499427 72522527 72599527 72622627 72699627 72722727 72799727 72822827 72899827 72922927 72999927 
8: 80611608 80622608 80633608 80644608 80655608 80666608 80677608 80688608 80699608 80800808 80811808 80822808 80833808 80844808 80855808 
9: 95311359 95400459 95499459 95588559 95677659 95766759 95855859 95944959 96033069 96122169 96211269 96300369 96399369 96488469 96577569 

~~==[ Last  10  of  1000  palindromic gapful numbers starting at 100 ]==~~
1: 17799771 17800871 17811871 17822871 17833871 17844871 17855871 17866871 17877871 17888871 
2: 27799772 27800872 27811872 27822872 27833872 27844872 27855872 27866872 27877872 27888872 
3: 3084004803 3084334803 3084664803 3084994803 3085225803 3085555803 3085885803 3086116803 3086446803 3086776803 
4: 482282284 482414284 482535284 482656284 482777284 482898284 482909284 483020384 483141384 483262384 
5: 57800875 57811875 57822875 57833875 57844875 57855875 57866875 57877875 57888875 57899875 
6: 6084004806 6084334806 6084664806 6084994806 6085225806 6085555806 6085885806 6086116806 6086446806 6086776806 
7: 7452992547 7453223547 7453993547 7454224547 7454994547 7455225547 7455995547 7456226547 7456996547 7457227547 
8: 8085995808 8086006808 8086116808 8086226808 8086336808 8086446808 8086556808 8086666808 8086776808 8086886808 
9: 9675005769 9675995769 9676886769 9677777769 9678668769 9679559769 9680440869 9681331869 9682222869 9683113869 

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]

This uses the same strategy as the Factor entry i.e. to generate all palindromic numbers in order and then test whether they're gapful or not.

To keep the Pascal entry company, I've extended the search to the first 10 million such numbers for each of the nine sets.

package main
 
import "fmt"
 
func reverse(s uint64) uint64 {
e := uint64(0)
for s > 0 {
e = e*10 + (s % 10)
s /= 10
}
return e
}
 
func commatize(n uint) 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 ord(n uint) string {
var suffix string
if n > 10 && ((n-11)%100 == 0 || (n-12)%100 == 0 || (n-13)%100 == 0) {
suffix = "th"
} else {
switch n % 10 {
case 1:
suffix = "st"
case 2:
suffix = "nd"
case 3:
suffix = "rd"
default:
suffix = "th"
}
}
return fmt.Sprintf("%s%s", commatize(n), suffix)
}
 
func main() {
const max = 10_000_000
data := [][3]uint{{1, 20, 7}, {86, 100, 8}, {991, 1000, 10}, {9995, 10000, 12}, {1e5, 1e5, 14},
{1e6, 1e6, 16}, {1e7, 1e7, 18}}
results := make(map[uint][]uint64)
for _, d := range data {
for i := d[0]; i <= d[1]; i++ {
results[i] = make([]uint64, 9)
}
}
var p uint64
outer:
for d := uint64(1); d < 10; d++ {
count := uint(0)
pow := uint64(1)
fl := d * 11
for nd := 3; nd < 20; nd++ {
slim := (d + 1) * pow
for s := d * pow; s < slim; s++ {
e := reverse(s)
mlim := uint64(1)
if nd%2 == 1 {
mlim = 10
}
for m := uint64(0); m < mlim; m++ {
if nd%2 == 0 {
p = s*pow*10 + e
} else {
p = s*pow*100 + m*pow*10 + e
}
if p%fl == 0 {
count++
if _, ok := results[count]; ok {
results[count][d-1] = p
}
if count == max {
continue outer
}
}
}
}
if nd%2 == 1 {
pow *= 10
}
}
}
 
for _, d := range data {
if d[0] != d[1] {
fmt.Printf("%s to %s palindromic gapful numbers (> 100) ending with:\n", ord(d[0]), ord(d[1]))
} else {
fmt.Printf("%s palindromic gapful number (> 100) ending with:\n", ord(d[0]))
}
for i := 1; i <= 9; i++ {
fmt.Printf("%d: ", i)
for j := d[0]; j <= d[1]; j++ {
fmt.Printf("%*d ", d[2], results[j][i-1])
}
fmt.Println()
}
fmt.Println()
}
}
Output:
1st to 20th palindromic gapful numbers (> 100) ending with:
1:     121    1001    1111    1221    1331    1441    1551    1661    1771    1881    1991   10901   11011   12221   13431   14641   15851   17171   18381   19591 
2:     242    2002    2112    2222    2332    2442    2552    2662    2772    2882    2992   20702   21912   22022   23232   24442   25652   26862   28182   29392 
3:     363    3003    3333    3663    3993   31713   33033   36663  300003  303303  306603  309903  312213  315513  318813  321123  324423  327723  330033  333333 
4:     484    4004    4224    4444    4664    4884   40304   42724   44044   46464   48884  400004  401104  402204  403304  404404  405504  406604  407704  408804 
5:    5005    5115    5225    5335    5445    5555    5665    5775    5885    5995   50105   51315   52525   53735   54945   55055   56265   57475   58685   59895 
6:    6006    6336    6666    6996   61116   64746   66066   69696  600006  603306  606606  609906  612216  615516  618816  621126  624426  627726  630036  633336 
7:    7007    7777   77077  700007  707707  710017  717717  720027  727727  730037  737737  740047  747747  750057  757757  760067  767767  770077  777777  780087 
8:    8008    8448    8888   80608   86768   88088  800008  802208  804408  806608  808808  821128  823328  825528  827728  829928  840048  842248  844448  846648 
9:    9009    9999   94149   99099  900009  909909  918819  927729  936639  945549  954459  963369  972279  981189  990099  999999 9459549 9508059 9557559 9606069 

86th to 100th palindromic gapful numbers (> 100) ending with:
1:   165561   166661   167761   168861   169961   170071   171171   172271   173371   174471   175571   176671   177771   178871   179971 
2:   265562   266662   267762   268862   269962   270072   271172   272272   273372   274472   275572   276672   277772   278872   279972 
3: 30366303 30399303 30422403 30455403 30488403 30511503 30544503 30577503 30600603 30633603 30666603 30699603 30722703 30755703 30788703 
4:  4473744  4485844  4497944  4607064  4619164  4620264  4632364  4644464  4656564  4668664  4681864  4693964  4803084  4815184  4827284 
5:   565565   566665   567765   568865   569965   570075   571175   572275   573375   574475   575575   576675   577775   578875   579975 
6: 60399306 60422406 60455406 60488406 60511506 60544506 60577506 60600606 60633606 60666606 60699606 60722706 60755706 60788706 60811806 
7: 72299227 72322327 72399327 72422427 72499427 72522527 72599527 72622627 72699627 72722727 72799727 72822827 72899827 72922927 72999927 
8: 80611608 80622608 80633608 80644608 80655608 80666608 80677608 80688608 80699608 80800808 80811808 80822808 80833808 80844808 80855808 
9: 95311359 95400459 95499459 95588559 95677659 95766759 95855859 95944959 96033069 96122169 96211269 96300369 96399369 96488469 96577569 

991st to 1,000th palindromic gapful numbers (> 100) ending with:
1:   17799771   17800871   17811871   17822871   17833871   17844871   17855871   17866871   17877871   17888871 
2:   27799772   27800872   27811872   27822872   27833872   27844872   27855872   27866872   27877872   27888872 
3: 3084004803 3084334803 3084664803 3084994803 3085225803 3085555803 3085885803 3086116803 3086446803 3086776803 
4:  482282284  482414284  482535284  482656284  482777284  482898284  482909284  483020384  483141384  483262384 
5:   57800875   57811875   57822875   57833875   57844875   57855875   57866875   57877875   57888875   57899875 
6: 6084004806 6084334806 6084664806 6084994806 6085225806 6085555806 6085885806 6086116806 6086446806 6086776806 
7: 7452992547 7453223547 7453993547 7454224547 7454994547 7455225547 7455995547 7456226547 7456996547 7457227547 
8: 8085995808 8086006808 8086116808 8086226808 8086336808 8086446808 8086556808 8086666808 8086776808 8086886808 
9: 9675005769 9675995769 9676886769 9677777769 9678668769 9679559769 9680440869 9681331869 9682222869 9683113869 

9,995th to 10,000th palindromic gapful numbers (> 100) ending with:
1:   1787447871   1787557871   1787667871   1787777871   1787887871   1787997871 
2:   2787447872   2787557872   2787667872   2787777872   2787887872   2787997872 
3: 308757757803 308760067803 308763367803 308766667803 308769967803 308772277803 
4:  48326662384  48327872384  48329192384  48330303384  48331513384  48332723384 
5:   5787447875   5787557875   5787667875   5787777875   5787887875   5787997875 
6: 608760067806 608763367806 608766667806 608769967806 608772277806 608775577806 
7: 746951159647 746958859647 746961169647 746968869647 746971179647 746978879647 
8: 808690096808 808691196808 808692296808 808693396808 808694496808 808695596808 
9: 968688886869 968697796869 968706607869 968715517869 968724427869 968733337869 

100,000th palindromic gapful number (> 100) ending with:
1:   178788887871 
2:   278788887872 
3: 30878611687803 
4:  4833326233384 
5:   578789987875 
6: 60878611687806 
7: 74826144162847 
8: 80869688696808 
9: 96878077087869 

1,000,000th palindromic gapful number (> 100) ending with:
1:   17878799787871 
2:   27878799787872 
3: 3087876666787803 
4:  483333272333384 
5:   57878799787875 
6: 6087876996787806 
7: 7487226666227847 
8: 8086969559696808 
9: 9687870990787869 

10,000,000th palindromic gapful number (> 100) ending with:
1:   1787878888787871 
2:   2787878888787872 
3: 308787855558787803 
4:  48333332623333384 
5:   5787878998787875 
6: 608787855558787806 
7: 748867523325768847 
8: 808696968869696808 
9: 968787783387787869 

Julia[edit]

import Base.iterate, Base.IteratorSize, Base.IteratorEltype
 
struct Palindrome x1::UInt8; x2::UInt8; outer::UInt8; end
Base.IteratorSize(p::Palindrome) = Base.IsInfinite()
Base.IteratorEltype(g::Palindrome) = Vector{Int8}
 
function Base.iterate(p::Palindrome, state=(UInt8[p.x1]))
arr, len = [p.outer; state; p.outer], length(state)
if all(c -> c == p.x2, state)
return arr, fill(p.x1, len + 1)
end
for i in (len+1)÷2:-1:1
if state[i] < p.x2
state[len - i + 1] = state[i] = state[i] + one(UInt8)
return arr, state
else
state[len - i + 1] = state[i] = p.x1
end
end
state[1] += one(UInt8)
push!(state, state[1])
return arr, state
end
 
asint(s) = foldl((i, j) -> 10i + j, s)
isgapful(a) = mod(asint(a), a[1] * 11) == 0
GapfulPalindrome(i) = Iterators.filter(isgapful, Iterators.take(Palindrome(0, 9, i), 100000000000))
 
function testpal()
for (lastones, outof) in [(20, 20), (15, 100), (10, 1000), (10, 10000), (10, 100000), (10, 1000000), (10, 10000000)]
@time begin
println("\nLast digit | Last $lastones of $outof palindromic gapful numbers from 100\n",
"-----------|----------------------------------------------------------------------------------------------------------------")
output = fill("", 9)
[email protected] for i in 1:9
gplist = sort!(asint.(collect(Iterators.take(GapfulPalindrome(i), outof))))
output[i] = " $i " * string(gplist[end-lastones+1:end]) * "\n"
end
foreach(print, output)
end
end
end
 
testpal()
 
Output:
Last digit | Last 20 of 20 palindromic gapful numbers from 100
-----------|------------------------------------------------------------------------------------------------------------------------
     1        [121, 1001, 1111, 1221, 1331, 1441, 1551, 1661, 1771, 1881, 1991, 10901, 11011, 12221, 13431, 14641, 15851, 17171, 18381, 19591]
     2        [242, 2002, 2112, 2222, 2332, 2442, 2552, 2662, 2772, 2882, 2992, 20702, 21912, 22022, 23232, 24442, 25652, 26862, 28182, 29392]
     3        [363, 3003, 3333, 3663, 3993, 31713, 33033, 36663, 300003, 303303, 306603, 309903, 312213, 315513, 318813, 321123, 324423, 327723, 330033, 333333]
     4        [484, 4004, 4224, 4444, 4664, 4884, 40304, 42724, 44044, 46464, 48884, 400004, 401104, 402204, 403304, 404404, 405504, 406604, 407704, 408804]
     5        [5005, 5115, 5225, 5335, 5445, 5555, 5665, 5775, 5885, 5995, 50105, 51315, 52525, 53735, 54945, 55055, 56265, 57475, 58685, 59895]
     6        [6006, 6336, 6666, 6996, 61116, 64746, 66066, 69696, 600006, 603306, 606606, 609906, 612216, 615516, 618816, 621126, 624426, 627726, 630036, 633336]
     7        [7007, 7777, 77077, 700007, 707707, 710017, 717717, 720027, 727727, 730037, 737737, 740047, 747747, 750057, 757757, 760067, 767767, 770077, 777777, 780087]
     8        [8008, 8448, 8888, 80608, 86768, 88088, 800008, 802208, 804408, 806608, 808808, 821128, 823328, 825528, 827728, 829928, 840048, 842248, 844448, 846648]
     9        [9009, 9999, 94149, 99099, 900009, 909909, 918819, 927729, 936639, 945549, 954459, 963369, 972279, 981189, 990099, 999999, 9459549, 9508059, 9557559, 9606069]
  0.623229 seconds (1.68 M allocations: 85.926 MiB, 2.02% gc time)

Last digit | Last 15 of 100 palindromic gapful numbers from 100
-----------|------------------------------------------------------------------------------------------------------------------------
     1        [165561, 166661, 167761, 168861, 169961, 170071, 171171, 172271, 173371, 174471, 175571, 176671, 177771, 178871, 179971]
     2        [265562, 266662, 267762, 268862, 269962, 270072, 271172, 272272, 273372, 274472, 275572, 276672, 277772, 278872, 279972]
     3        [30366303, 30399303, 30422403, 30455403, 30488403, 30511503, 30544503, 30577503, 30600603, 30633603, 30666603, 30699603, 30722703, 30755703, 30788703]
     4        [4473744, 4485844, 4497944, 4607064, 4619164, 4620264, 4632364, 4644464, 4656564, 4668664, 4681864, 4693964, 4803084, 4815184, 4827284]
     5        [565565, 566665, 567765, 568865, 569965, 570075, 571175, 572275, 573375, 574475, 575575, 576675, 577775, 578875, 579975]
     6        [60399306, 60422406, 60455406, 60488406, 60511506, 60544506, 60577506, 60600606, 60633606, 60666606, 60699606, 60722706, 60755706, 60788706, 60811806]
     7        [72299227, 72322327, 72399327, 72422427, 72499427, 72522527, 72599527, 72622627, 72699627, 72722727, 72799727, 72822827, 72899827, 72922927, 72999927]
     8        [80611608, 80622608, 80633608, 80644608, 80655608, 80666608, 80677608, 80688608, 80699608, 80800808, 80811808, 80822808, 80833808, 80844808, 80855808]
     9        [95311359, 95400459, 95499459, 95588559, 95677659, 95766759, 95855859, 95944959, 96033069, 96122169, 96211269, 96300369, 96399369, 96488469, 96577569]
  0.011659 seconds (125.64 k allocations: 4.389 MiB)

Last digit | Last 10 of 1000 palindromic gapful numbers from 100
-----------|------------------------------------------------------------------------------------------------------------------------
     1        [17799771, 17800871, 17811871, 17822871, 17833871, 17844871, 17855871, 17866871, 17877871, 17888871]
     2        [27799772, 27800872, 27811872, 27822872, 27833872, 27844872, 27855872, 27866872, 27877872, 27888872]
     3        [3084004803, 3084334803, 3084664803, 3084994803, 3085225803, 3085555803, 3085885803, 3086116803, 3086446803, 3086776803]
     4        [482282284, 482414284, 482535284, 482656284, 482777284, 482898284, 482909284, 483020384, 483141384, 483262384]
     5        [57800875, 57811875, 57822875, 57833875, 57844875, 57855875, 57866875, 57877875, 57888875, 57899875]
     6        [6084004806, 6084334806, 6084664806, 6084994806, 6085225806, 6085555806, 6085885806, 6086116806, 6086446806, 6086776806]
     7        [7452992547, 7453223547, 7453993547, 7454224547, 7454994547, 7455225547, 7455995547, 7456226547, 7456996547, 7457227547]
     8        [8085995808, 8086006808, 8086116808, 8086226808, 8086336808, 8086446808, 8086556808, 8086666808, 8086776808, 8086886808]
     9        [9675005769, 9675995769, 9676886769, 9677777769, 9678668769, 9679559769, 9680440869, 9681331869, 9682222869, 9683113869]
  0.121723 seconds (1.31 M allocations: 45.342 MiB, 23.28% gc time)

Last digit | Last 10 of 10000 palindromic gapful numbers from 100
-----------|------------------------------------------------------------------------------------------------------------------------
     1        [1787007871, 1787117871, 1787227871, 1787337871, 1787447871, 1787557871, 1787667871, 1787777871, 1787887871, 1787997871]
     2        [2787007872, 2787117872, 2787227872, 2787337872, 2787447872, 2787557872, 2787667872, 2787777872, 2787887872, 2787997872]
     3        [308745547803, 308748847803, 308751157803, 308754457803, 308757757803, 308760067803, 308763367803, 308766667803, 308769967803, 308772277803]
     4        [48322922384, 48323032384, 48324242384, 48325452384, 48326662384, 48327872384, 48329192384, 48330303384, 48331513384, 48332723384]
     5        [5787007875, 5787117875, 5787227875, 5787337875, 5787447875, 5787557875, 5787667875, 5787777875, 5787887875, 5787997875]
     6        [608748847806, 608751157806, 608754457806, 608757757806, 608760067806, 608763367806, 608766667806, 608769967806, 608772277806, 608775577806]
     7        [746931139647, 746938839647, 746941149647, 746948849647, 746951159647, 746958859647, 746961169647, 746968869647, 746971179647, 746978879647]
     8        [808686686808, 808687786808, 808688886808, 808689986808, 808690096808, 808691196808, 808692296808, 808693396808, 808694496808, 808695596808]
     9        [968652256869, 968661166869, 968670076869, 968679976869, 968688886869, 968697796869, 968706607869, 968715517869, 968724427869, 968733337869]
  1.194631 seconds (13.03 M allocations: 452.216 MiB, 19.09% gc time)

Last digit | Last 10 of 100000 palindromic gapful numbers from 100
-----------|------------------------------------------------------------------------------------------------------------------------
     1        [178779977871, 178780087871, 178781187871, 178782287871, 178783387871, 178784487871, 178785587871, 178786687871, 178787787871, 178788887871]
     2        [278779977872, 278780087872, 278781187872, 278782287872, 278783387872, 278784487872, 278785587872, 278786687872, 278787787872, 278788887872]
     3        [30878344387803, 30878377387803, 30878400487803, 30878433487803, 30878466487803, 30878499487803, 30878522587803, 30878555587803, 30878588587803, 30878611687803]
     4        [4833228223384, 4833241423384, 4833253523384, 4833265623384, 4833277723384, 4833289823384, 4833290923384, 4833302033384, 4833314133384, 4833326233384]
     5        [578780087875, 578781187875, 578782287875, 578783387875, 578784487875, 578785587875, 578786687875, 578787787875, 578788887875, 578789987875]
     6        [60878344387806, 60878377387806, 60878400487806, 60878433487806, 60878466487806, 60878499487806, 60878522587806, 60878555587806, 60878588587806, 60878611687806]
     7        [74825233252847, 74825333352847, 74825433452847, 74825533552847, 74825633652847, 74825733752847, 74825833852847, 74825933952847, 74826044062847, 74826144162847]
     8        [80869599596808, 80869600696808, 80869611696808, 80869622696808, 80869633696808, 80869644696808, 80869655696808, 80869666696808, 80869677696808, 80869688696808]
     9        [96877266277869, 96877355377869, 96877444477869, 96877533577869, 96877622677869, 96877711777869, 96877800877869, 96877899877869, 96877988977869, 96878077087869]
 10.614688 seconds (129.23 M allocations: 4.349 GiB, 14.81% gc time)

Last digit | Last 10 of 1000000 palindromic gapful numbers from 100
-----------|------------------------------------------------------------------------------------------------------------------------
     1        [17878700787871, 17878711787871, 17878722787871, 17878733787871, 17878744787871, 17878755787871, 17878766787871, 17878777787871, 17878788787871, 17878799787871]
     2        [27878700787872, 27878711787872, 27878722787872, 27878733787872, 27878744787872, 27878755787872, 27878766787872, 27878777787872, 27878788787872, 27878799787872]
     3        [3087873993787803, 3087874224787803, 3087874554787803, 3087874884787803, 3087875115787803, 3087875445787803, 3087875775787803, 3087876006787803, 3087876336787803, 3087876666787803]
     4        [483332292233384, 483332303233384, 483332424233384, 483332545233384, 483332666233384, 483332787233384, 483332919233384, 483333030333384, 483333151333384, 483333272333384]
     5        [57878700787875, 57878711787875, 57878722787875, 57878733787875, 57878744787875, 57878755787875, 57878766787875, 57878777787875, 57878788787875, 57878799787875]
     6        [6087874224787806, 6087874554787806, 6087874884787806, 6087875115787806, 6087875445787806, 6087875775787806, 6087876006787806, 6087876336787806, 6087876666787806, 6087876996787806]
     7        [7487217557127847, 7487218558127847, 7487219559127847, 7487220660227847, 7487221661227847, 7487222662227847, 7487223663227847, 7487224664227847, 7487225665227847, 7487226666227847]
     8        [8086968668696808, 8086968778696808, 8086968888696808, 8086968998696808, 8086969009696808, 8086969119696808, 8086969229696808, 8086969339696808, 8086969449696808, 8086969559696808]
     9        [9687862882687869, 9687863773687869, 9687864664687869, 9687865555687869, 9687866446687869, 9687867337687869, 9687868228687869, 9687869119687869, 9687870000787869, 9687870990787869]
114.847779 seconds (1.28 G allocations: 43.170 GiB, 19.29% gc time)

Last digit | Last 10 of 10000000 palindromic gapful numbers from 100
-----------|------------------------------------------------------------------------------------------------------------------------
     1        [1787877997787871, 1787878008787871, 1787878118787871, 1787878228787871, 1787878338787871, 1787878448787871, 1787878558787871, 1787878668787871, 1787878778787871, 1787878888787871]
     2        [2787877997787872, 2787878008787872, 2787878118787872, 2787878228787872, 2787878338787872, 2787878448787872, 2787878558787872, 2787878668787872, 2787878778787872, 2787878888787872]
     3        [308787828828787803, 308787831138787803, 308787834438787803, 308787837738787803, 308787840048787803, 308787843348787803, 308787846648787803, 308787849948787803, 308787852258787803, 308787855558787803]
     4        [48333322822333384, 48333324142333384, 48333325352333384, 48333326562333384, 48333327772333384, 48333328982333384, 48333329092333384, 48333330203333384, 48333331413333384, 48333332623333384]
     5        [5787878008787875, 5787878118787875, 5787878228787875, 5787878338787875, 5787878448787875, 5787878558787875, 5787878668787875, 5787878778787875, 5787878888787875, 5787878998787875]
     6        [608787828828787806, 608787831138787806, 608787834438787806, 608787837738787806, 608787840048787806, 608787843348787806, 608787846648787806, 608787849948787806, 608787852258787806, 608787855558787806]
     7        [748867469964768847, 748867472274768847, 748867479974768847, 748867482284768847, 748867489984768847, 748867492294768847, 748867499994768847, 748867503305768847, 748867513315768847, 748867523325768847]
     8        [808696959959696808, 808696960069696808, 808696961169696808, 808696962269696808, 808696963369696808, 808696964469696808, 808696965569696808, 808696966669696808, 808696967769696808, 808696968869696808]
     9        [968787702207787869, 968787711117787869, 968787720027787869, 968787729927787869, 968787738837787869, 968787747747787869, 968787756657787869, 968787765567787869, 968787774477787869, 968787783387787869]
1770.411549 seconds (13.02 G allocations: 443.799 GiB, 40.12% gc time)

Pascal[edit]

Works with: Free Pascal

Creating palindromes by adding the right numbers one by one and the precalculated modulus of that numbers
So the numbers to check stays small in bitsize modsum ~16 Bit , n ~ 64 Bit.Dividing is therefore faster
Thinking about it, you don't need n = Uint64, only the value of the digit in that place is enough.
Of course this task has no relevance see digit 9 from 100,000 to 10,000,000

9 :   96878077087869
9 :  9687870990787869
9 : 968787783387787869
program PalinGap;
{$IFDEF FPC}
{$MODE DELPHI}{$OPTIMIZATION ON,ALL}{$CODEALIGN proc=16}{$ALIGN 16}
{$ELSE}
{$APPTYPE CONSOLE}
{$ENDIF}
//example 5 digits, digit d
// d000d
// +00100 10 -times delta[0] aka middle digit
//->d010d d020d d030d d040d d050d d060d d070d d080d d090d and
// d100d -> not palindromatic
//correct by -10x00100 and use the next delta for the next digitplaces
// d000d
//+ 01010 -> delta[1]
// d101d
// starting over again with delta[0] until delta[1] is used 10 times
type
tLimits = record
LoLmt,HiLmt:Uint64;
end;
const
base = 10;
 
var
delta : Array[0..9] of Uint64;
deltaBase: Array[0..9] of Uint64;
deltaMod : Array[0..9] of Uint32;
deltaModBase : Array[0..9] of Uint32;
 
IdxCnt : Array[0..9] of Uint32;
ModSum : UInt64;
dgtMod : UInt32;
 
procedure InitDelta(dgt:Byte;dgtCnt:Byte);
var
n : Uint64;
i,k,mid : NativeInt;
Begin
mid := (dgtCnt-1) DIV 2;
//create Add masks
For i := 0 to mid do
Begin
IF ODD(dgtCnt) then
//first 1,101,10001,1000001,100000001,10000000001
Begin
n := 1;
IF i> 0 then
Begin
For k := 1 to i do
n := n*(Base*Base);
inc(n);
end
end
Else //even
// first 11,1001,100001,10000001...
Begin
n := Base;
For k := 1 to i do
n := n*(Base*Base);
inc(n);
end;
// second move to the right place
// 1000000,10100000,10001000,10000010,100000001
dgtMod := (dgt*(Base+1));
For k := mid-1 DOWNTO i do
n := n*Base;
 
delta[i] := n;
deltaMod[i]:= n MOD dgtMod;
deltaBase[i] := base*n;
deltaModBase[i]:= (base*n) MOD dgtMod;
end;
//counter for digit position
For k := 0 to 9 do
IdxCnt[k] := Base;
end;
 
function NextPalin(n : Uint64;dgtcnt:NativeInt):Uint64;inline;
var
k,b: NativeInt;
begin
k := 0;
repeat
n := n+delta[k];
inc(ModSum,deltaMod[k]);
b := IdxCnt[k]-1;
IdxCnt[k]:= b;
IF b <> 0 then
break
else
Begin
n := n-deltaBase[k];
dec(ModSum,deltaModBase[k]);
IdxCnt[k]:= Base;
inc(k);
IF k = dgtCnt then
Begin
n := 0;
BREAK;
end;
end;
until false;
NextPalin := n;
end;
 
procedure OutPalinGap(lowLmt,HiLmt,dgt:NativeInt);
var
n : Uint64;
i,dgtcnt,mid :NativeInt;
begin
i:=1;
write(dgt,' :');
For dgtcnt := 3 to 20 do
Begin
mid := (dgtcnt-1) shr 1;
initDelta(dgt,dgtcnt);
n := dgt*delta[mid];// '10...01' -> 'd0...0d'
ModSum := n MOD dgtMod;
 
while (n <>0) AND (i< LowLmt) do
Begin
IF (ModSum MOD dgtMod) = 0 then
Begin
inc(i);
ModSum :=0;//reduce Modsum
end;
n := NextPalin(n,mid);
end;
 
while (n <>0) AND (i<= HiLmt) do
Begin
IF (ModSum MOD dgtMod) = 0 then
Begin
inc(i);
write(n:dgtcnt+1);
ModSum :=0;//reduce Modsum
end;
n := NextPalin(n,mid);
end;
IF (i > HiLmt) then
BREAK;
end;
writeln;
end;
 
var
dgt : NativeInt;
begin
writeln('palindromic gapful numbers from 1 to 20');
For dgt := 1 to 9 do
OutPalinGap(1,20,dgt);
writeln;
writeln('palindromic gapful numbers from 86 to 100');
For dgt := 1 to 9 do
OutPalinGap(86,100,dgt);
writeln;
writeln('palindromic gapful numbers from 991 to 1000');
For dgt := 1 to 9 do
OutPalinGap(991,1000,dgt);
writeln;
writeln('palindromic gapful number 100,000');
For dgt := 1 to 9 do
OutPalinGap(100000,100000,dgt);
writeln;
writeln('palindromic gapful number 1,000,000');
For dgt := 1 to 9 do
OutPalinGap(1000000,1000000,dgt);
writeln;
writeln('palindromic gapful number 10,000,000');
For dgt := 1 to 9 do
OutPalinGap(10000000,10000000,dgt);
writeln;
end.
Output:

palindromic gapful numbers from 1 to 20 1 : 121 1001 1111 1221 1331 1441 1551 1661 1771 1881 1991 10901 11011 12221 13431 14641 15851 17171 18381 19591 2 : 242 2002 2112 2222 2332 2442 2552 2662 2772 2882 2992 20702 21912 22022 23232 24442 25652 26862 28182 29392 3 : 363 3003 3333 3663 3993 31713 33033 36663 300003 303303 306603 309903 312213 315513 318813 321123 324423 327723 330033 333333 4 : 484 4004 4224 4444 4664 4884 40304 42724 44044 46464 48884 400004 401104 402204 403304 404404 405504 406604 407704 408804 5 : 5005 5115 5225 5335 5445 5555 5665 5775 5885 5995 50105 51315 52525 53735 54945 55055 56265 57475 58685 59895 6 : 6006 6336 6666 6996 61116 64746 66066 69696 600006 603306 606606 609906 612216 615516 618816 621126 624426 627726 630036 633336 7 : 7007 7777 77077 700007 707707 710017 717717 720027 727727 730037 737737 740047 747747 750057 757757 760067 767767 770077 777777 780087 8 : 8008 8448 8888 80608 86768 88088 800008 802208 804408 806608 808808 821128 823328 825528 827728 829928 840048 842248 844448 846648 9 : 9009 9999 94149 99099 900009 909909 918819 927729 936639 945549 954459 963369 972279 981189 990099 999999 9459549 9508059 9557559 9606069

palindromic gapful numbers from 86 to 100 1 : 165561 166661 167761 168861 169961 170071 171171 172271 173371 174471 175571 176671 177771 178871 179971 2 : 265562 266662 267762 268862 269962 270072 271172 272272 273372 274472 275572 276672 277772 278872 279972 3 : 30366303 30399303 30422403 30455403 30488403 30511503 30544503 30577503 30600603 30633603 30666603 30699603 30722703 30755703 30788703 4 : 4473744 4485844 4497944 4607064 4619164 4620264 4632364 4644464 4656564 4668664 4681864 4693964 4803084 4815184 4827284 5 : 565565 566665 567765 568865 569965 570075 571175 572275 573375 574475 575575 576675 577775 578875 579975 6 : 60399306 60422406 60455406 60488406 60511506 60544506 60577506 60600606 60633606 60666606 60699606 60722706 60755706 60788706 60811806 7 : 72299227 72322327 72399327 72422427 72499427 72522527 72599527 72622627 72699627 72722727 72799727 72822827 72899827 72922927 72999927 8 : 80611608 80622608 80633608 80644608 80655608 80666608 80677608 80688608 80699608 80800808 80811808 80822808 80833808 80844808 80855808 9 : 95311359 95400459 95499459 95588559 95677659 95766759 95855859 95944959 96033069 96122169 96211269 96300369 96399369 96488469 96577569

palindromic gapful numbers from 991 to 1000 1 : 17799771 17800871 17811871 17822871 17833871 17844871 17855871 17866871 17877871 17888871 2 : 27799772 27800872 27811872 27822872 27833872 27844872 27855872 27866872 27877872 27888872 3 : 3084004803 3084334803 3084664803 3084994803 3085225803 3085555803 3085885803 3086116803 3086446803 3086776803 4 : 482282284 482414284 482535284 482656284 482777284 482898284 482909284 483020384 483141384 483262384 5 : 57800875 57811875 57822875 57833875 57844875 57855875 57866875 57877875 57888875 57899875 6 : 6084004806 6084334806 6084664806 6084994806 6085225806 6085555806 6085885806 6086116806 6086446806 6086776806 7 : 7452992547 7453223547 7453993547 7454224547 7454994547 7455225547 7455995547 7456226547 7456996547 7457227547 8 : 8085995808 8086006808 8086116808 8086226808 8086336808 8086446808 8086556808 8086666808 8086776808 8086886808 9 : 9675005769 9675995769 9676886769 9677777769 9678668769 9679559769 9680440869 9681331869 9682222869 9683113869

palindromic gapful number 100,000 1 : 178788887871 2 : 278788887872 3 : 30878611687803 4 : 4833326233384 5 : 578789987875 6 : 60878611687806 7 : 74826144162847 8 : 80869688696808 9 : 96878077087869

palindromic gapful number 1,000,000 1 : 17878799787871 2 : 27878799787872 3 : 3087876666787803 4 : 483333272333384 5 : 57878799787875 6 : 6087876996787806 7 : 7487226666227847 8 : 8086969559696808 9 : 9687870990787869

palindromic gapful number 10,000,000 1 : 1787878888787871 2 : 2787878888787872 3 : 308787855558787803 4 : 48333332623333384 5 : 5787878998787875 6 : 608787855558787806 7 : 748867523325768847 8 : 808696968869696808 9 : 968787783387787869

real 0m4,503s

Perl 6[edit]

Works with: Rakudo version 2019.07.1
# Infinite lazy iterator to generate palindromic "gap" numbers
my @npal = flat [ ^10 ], [ ^10 .map: * x 2 ],
{
sink @^previous;
my \count = +@^penultimate;
[ flat ^10 .map: -> \digit { digit xx count Z~ @penultimate Z~ digit xx count } ]
}*;
 
# Individual lazy palindromic gapful number iterators for each start/end digit
my @gappal = (1..9).map: -> \digit {
my \divisor = digit + 10 * digit;
@npal.map: -> \this { next unless (my \test = digit ~ this ~ digit) %% divisor; test }
}
 
# Display
for "(Required) First 20 gapful palindromes:", ^20, 7
,"\n(Required) 86th through 100th:", 85..99, 8
,"\n(Optional) 991st through 1,000th:", 990..999, 10
,"\n(Extra stretchy) 9,995th through 10,000th:", 9994..9999, 12
,"\n(Meh) 100,000th:", 99999, 14
-> $caption, $range, $fmt {
my $now = now;
say $caption;
put "$_: " ~ @gappal[$_-1][|$range].fmt("%{$fmt}s") for 1..9;
say round( now - $now, .001 ), " seconds";
}
Output:
(Required) First 20 gapful palindromes:
1:     121    1001    1111    1221    1331    1441    1551    1661    1771    1881    1991   10901   11011   12221   13431   14641   15851   17171   18381   19591
2:     242    2002    2112    2222    2332    2442    2552    2662    2772    2882    2992   20702   21912   22022   23232   24442   25652   26862   28182   29392
3:     363    3003    3333    3663    3993   31713   33033   36663  300003  303303  306603  309903  312213  315513  318813  321123  324423  327723  330033  333333
4:     484    4004    4224    4444    4664    4884   40304   42724   44044   46464   48884  400004  401104  402204  403304  404404  405504  406604  407704  408804
5:    5005    5115    5225    5335    5445    5555    5665    5775    5885    5995   50105   51315   52525   53735   54945   55055   56265   57475   58685   59895
6:    6006    6336    6666    6996   61116   64746   66066   69696  600006  603306  606606  609906  612216  615516  618816  621126  624426  627726  630036  633336
7:    7007    7777   77077  700007  707707  710017  717717  720027  727727  730037  737737  740047  747747  750057  757757  760067  767767  770077  777777  780087
8:    8008    8448    8888   80608   86768   88088  800008  802208  804408  806608  808808  821128  823328  825528  827728  829928  840048  842248  844448  846648
9:    9009    9999   94149   99099  900009  909909  918819  927729  936639  945549  954459  963369  972279  981189  990099  999999 9459549 9508059 9557559 9606069
0.048 seconds

(Required) 86th through 100th:
1:   165561   166661   167761   168861   169961   170071   171171   172271   173371   174471   175571   176671   177771   178871   179971
2:   265562   266662   267762   268862   269962   270072   271172   272272   273372   274472   275572   276672   277772   278872   279972
3: 30366303 30399303 30422403 30455403 30488403 30511503 30544503 30577503 30600603 30633603 30666603 30699603 30722703 30755703 30788703
4:  4473744  4485844  4497944  4607064  4619164  4620264  4632364  4644464  4656564  4668664  4681864  4693964  4803084  4815184  4827284
5:   565565   566665   567765   568865   569965   570075   571175   572275   573375   574475   575575   576675   577775   578875   579975
6: 60399306 60422406 60455406 60488406 60511506 60544506 60577506 60600606 60633606 60666606 60699606 60722706 60755706 60788706 60811806
7: 72299227 72322327 72399327 72422427 72499427 72522527 72599527 72622627 72699627 72722727 72799727 72822827 72899827 72922927 72999927
8: 80611608 80622608 80633608 80644608 80655608 80666608 80677608 80688608 80699608 80800808 80811808 80822808 80833808 80844808 80855808
9: 95311359 95400459 95499459 95588559 95677659 95766759 95855859 95944959 96033069 96122169 96211269 96300369 96399369 96488469 96577569
0.046 seconds

(Optional) 991st through 1,000th:
1:   17799771   17800871   17811871   17822871   17833871   17844871   17855871   17866871   17877871   17888871
2:   27799772   27800872   27811872   27822872   27833872   27844872   27855872   27866872   27877872   27888872
3: 3084004803 3084334803 3084664803 3084994803 3085225803 3085555803 3085885803 3086116803 3086446803 3086776803
4:  482282284  482414284  482535284  482656284  482777284  482898284  482909284  483020384  483141384  483262384
5:   57800875   57811875   57822875   57833875   57844875   57855875   57866875   57877875   57888875   57899875
6: 6084004806 6084334806 6084664806 6084994806 6085225806 6085555806 6085885806 6086116806 6086446806 6086776806
7: 7452992547 7453223547 7453993547 7454224547 7454994547 7455225547 7455995547 7456226547 7456996547 7457227547
8: 8085995808 8086006808 8086116808 8086226808 8086336808 8086446808 8086556808 8086666808 8086776808 8086886808
9: 9675005769 9675995769 9676886769 9677777769 9678668769 9679559769 9680440869 9681331869 9682222869 9683113869
0.417 seconds

(Extra stretchy) 9,995th through 10,000th:
1:   1787447871   1787557871   1787667871   1787777871   1787887871   1787997871
2:   2787447872   2787557872   2787667872   2787777872   2787887872   2787997872
3: 308757757803 308760067803 308763367803 308766667803 308769967803 308772277803
4:  48326662384  48327872384  48329192384  48330303384  48331513384  48332723384
5:   5787447875   5787557875   5787667875   5787777875   5787887875   5787997875
6: 608760067806 608763367806 608766667806 608769967806 608772277806 608775577806
7: 746951159647 746958859647 746961169647 746968869647 746971179647 746978879647
8: 808690096808 808691196808 808692296808 808693396808 808694496808 808695596808
9: 968688886869 968697796869 968706607869 968715517869 968724427869 968733337869
5.626 seconds

(Meh) 100,000th:
1:   178788887871
2:   278788887872
3: 30878611687803
4:  4833326233384
5:   578789987875
6: 60878611687806
7: 74826144162847
8: 80869688696808
9: 96878077087869
65.004 seconds

Phix[edit]

Translation of: Go

Translation of Go, but trimmed back to bare minimum: you should not expect this to fare particularly well at the 10_000_000-level against the likes of Go/Pascal, though it should fare reasonably well against lesser beings...

function reverse_n(atom s)
atom e = 0
while s>0 do
e = e*10 + remainder(s,10)
s = floor(s/10)
end while
return e
end function
 
constant mx = 1000,
data = {{1, 20, "%7d "}, {86, 100, "%8d "}, {991, 1000, "%10d "}}
 
include builtins\ordinal.e
 
procedure main()
sequence results = repeat(repeat({},9),mx)
for d=1 to 9 do -- (the start/end digit)
integer count = 0, pow = 1, fl = d*11
for nd=3 to 15 do -- (number of digits, usually quits early)
-- (obvs. 64-bit phix is fine with 19 digits, but 32-bit ain't)
bool odd = (remainder(nd,2)==1)
for s=d*pow to (d+1)*pow-1 do -- (eg 300 to 399)
integer e = reverse_n(s)
for m=0 to iff(odd?9:0) do -- (1 or 10 iterations)
atom p = e + iff(odd ? s*pow*100+m*pow*10
 : s*pow*10)
if remainder(p,fl)==0 then -- gapful!
count += 1
results[count][d] = p
-- (see? goto /is/ sometimes useful :-))
if count==mx then #ilASM{jmp :outer} end if
end if
end for
end for
if odd then pow *= 10 end if
end for
if count<mx then ?9/0 end if -- oh dear...
#ilASM{::outer}
end for
 
for i=1 to length(data) do
{integer s, integer e, string fmt} = data[i]
printf(1,"%,d%s to %,d%s palindromic gapful numbers (> 100) ending with:\n", {s,ord(s),e,ord(e)})
for d=1 to 9 do
printf(1,"%d: ",d)
for j=s to e do
printf(1,fmt,results[j][d])
end for
printf(1,"\n")
end for
printf(1,"\n")
end for
end procedure
main()
Output:
1st to 20th palindromic gapful numbers (> 100) ending with:
1:     121    1001    1111    1221    1331    1441    1551    1661    1771    1881    1991   10901   11011   12221   13431   14641   15851   17171   18381   19591
2:     242    2002    2112    2222    2332    2442    2552    2662    2772    2882    2992   20702   21912   22022   23232   24442   25652   26862   28182   29392
3:     363    3003    3333    3663    3993   31713   33033   36663  300003  303303  306603  309903  312213  315513  318813  321123  324423  327723  330033  333333
4:     484    4004    4224    4444    4664    4884   40304   42724   44044   46464   48884  400004  401104  402204  403304  404404  405504  406604  407704  408804
5:    5005    5115    5225    5335    5445    5555    5665    5775    5885    5995   50105   51315   52525   53735   54945   55055   56265   57475   58685   59895
6:    6006    6336    6666    6996   61116   64746   66066   69696  600006  603306  606606  609906  612216  615516  618816  621126  624426  627726  630036  633336
7:    7007    7777   77077  700007  707707  710017  717717  720027  727727  730037  737737  740047  747747  750057  757757  760067  767767  770077  777777  780087
8:    8008    8448    8888   80608   86768   88088  800008  802208  804408  806608  808808  821128  823328  825528  827728  829928  840048  842248  844448  846648
9:    9009    9999   94149   99099  900009  909909  918819  927729  936639  945549  954459  963369  972279  981189  990099  999999 9459549 9508059 9557559 9606069

86th to 100th palindromic gapful numbers (> 100) ending with:
1:   165561   166661   167761   168861   169961   170071   171171   172271   173371   174471   175571   176671   177771   178871   179971
2:   265562   266662   267762   268862   269962   270072   271172   272272   273372   274472   275572   276672   277772   278872   279972
3: 30366303 30399303 30422403 30455403 30488403 30511503 30544503 30577503 30600603 30633603 30666603 30699603 30722703 30755703 30788703
4:  4473744  4485844  4497944  4607064  4619164  4620264  4632364  4644464  4656564  4668664  4681864  4693964  4803084  4815184  4827284
5:   565565   566665   567765   568865   569965   570075   571175   572275   573375   574475   575575   576675   577775   578875   579975
6: 60399306 60422406 60455406 60488406 60511506 60544506 60577506 60600606 60633606 60666606 60699606 60722706 60755706 60788706 60811806
7: 72299227 72322327 72399327 72422427 72499427 72522527 72599527 72622627 72699627 72722727 72799727 72822827 72899827 72922927 72999927
8: 80611608 80622608 80633608 80644608 80655608 80666608 80677608 80688608 80699608 80800808 80811808 80822808 80833808 80844808 80855808
9: 95311359 95400459 95499459 95588559 95677659 95766759 95855859 95944959 96033069 96122169 96211269 96300369 96399369 96488469 96577569

991st to 1,000th palindromic gapful numbers (> 100) ending with:
1:   17799771   17800871   17811871   17822871   17833871   17844871   17855871   17866871   17877871   17888871
2:   27799772   27800872   27811872   27822872   27833872   27844872   27855872   27866872   27877872   27888872
3: 3084004803 3084334803 3084664803 3084994803 3085225803 3085555803 3085885803 3086116803 3086446803 3086776803
4:  482282284  482414284  482535284  482656284  482777284  482898284  482909284  483020384  483141384  483262384
5:   57800875   57811875   57822875   57833875   57844875   57855875   57866875   57877875   57888875   57899875
6: 6084004806 6084334806 6084664806 6084994806 6085225806 6085555806 6085885806 6086116806 6086446806 6086776806
7: 7452992547 7453223547 7453993547 7454224547 7454994547 7455225547 7455995547 7456226547 7456996547 7457227547
8: 8085995808 8086006808 8086116808 8086226808 8086336808 8086446808 8086556808 8086666808 8086776808 8086886808
9: 9675005769 9675995769 9676886769 9677777769 9678668769 9679559769 9680440869 9681331869 9682222869 9683113869

Python[edit]

Generators[edit]

Uses the technique of:

  1. generating all odd number of digits palindromes, in order.
  2. generating all even number of digits palindromes, in order.
  3. merge sorting those (unbounded) generators.
  4. then filtering the palindromes for gapful palindromic numbers >= 100

With the number generator the binning was straight-forward.
Runtime is short.

Note: Although this uses the idea of generating palindromes from the Geeks4geeks reference mentioned in the Factor entry, none of their code was used.

from itertools import count
from pprint import pformat
import re
import heapq
 
 
def pal_part_gen(odd=True):
for i in count(1):
fwd = str(i)
rev = fwd[::-1][1:] if odd else fwd[::-1]
yield int(fwd + rev)
 
def pal_ordered_gen():
yield from heapq.merge(pal_part_gen(odd=True), pal_part_gen(odd=False))
 
def is_gapful(x):
return (x % (int(str(x)[0]) * 10 + (x % 10)) == 0)
 
if __name__ == '__main__':
start = 100
for mx, last in [(20, 20), (100, 15), (1_000, 10)]:
print(f"\nLast {last} of the first {mx} binned-by-last digit "
f"gapful numbers >= {start}")
bin = {i: [] for i in range(1, 10)}
gen = (i for i in pal_ordered_gen() if i >= start and is_gapful(i))
while any(len(val) < mx for val in bin.values()):
g = next(gen)
val = bin[g % 10]
if len(val) < mx:
val.append(g)
b = {k:v[-last:] for k, v in bin.items()}
txt = pformat(b, width=220)
print('', re.sub(r"[{},\[\]]", '', txt))
Output:
Last 20 of the first 20 binned-by-last digit gapful numbers >= 100
 1: 121 1001 1111 1221 1331 1441 1551 1661 1771 1881 1991 10901 11011 12221 13431 14641 15851 17171 18381 19591
 2: 242 2002 2112 2222 2332 2442 2552 2662 2772 2882 2992 20702 21912 22022 23232 24442 25652 26862 28182 29392
 3: 363 3003 3333 3663 3993 31713 33033 36663 300003 303303 306603 309903 312213 315513 318813 321123 324423 327723 330033 333333
 4: 484 4004 4224 4444 4664 4884 40304 42724 44044 46464 48884 400004 401104 402204 403304 404404 405504 406604 407704 408804
 5: 5005 5115 5225 5335 5445 5555 5665 5775 5885 5995 50105 51315 52525 53735 54945 55055 56265 57475 58685 59895
 6: 6006 6336 6666 6996 61116 64746 66066 69696 600006 603306 606606 609906 612216 615516 618816 621126 624426 627726 630036 633336
 7: 7007 7777 77077 700007 707707 710017 717717 720027 727727 730037 737737 740047 747747 750057 757757 760067 767767 770077 777777 780087
 8: 8008 8448 8888 80608 86768 88088 800008 802208 804408 806608 808808 821128 823328 825528 827728 829928 840048 842248 844448 846648
 9: 9009 9999 94149 99099 900009 909909 918819 927729 936639 945549 954459 963369 972279 981189 990099 999999 9459549 9508059 9557559 9606069

Last 15 of the first 100 binned-by-last digit gapful numbers >= 100
 1: 165561 166661 167761 168861 169961 170071 171171 172271 173371 174471 175571 176671 177771 178871 179971
 2: 265562 266662 267762 268862 269962 270072 271172 272272 273372 274472 275572 276672 277772 278872 279972
 3: 30366303 30399303 30422403 30455403 30488403 30511503 30544503 30577503 30600603 30633603 30666603 30699603 30722703 30755703 30788703
 4: 4473744 4485844 4497944 4607064 4619164 4620264 4632364 4644464 4656564 4668664 4681864 4693964 4803084 4815184 4827284
 5: 565565 566665 567765 568865 569965 570075 571175 572275 573375 574475 575575 576675 577775 578875 579975
 6: 60399306 60422406 60455406 60488406 60511506 60544506 60577506 60600606 60633606 60666606 60699606 60722706 60755706 60788706 60811806
 7: 72299227 72322327 72399327 72422427 72499427 72522527 72599527 72622627 72699627 72722727 72799727 72822827 72899827 72922927 72999927
 8: 80611608 80622608 80633608 80644608 80655608 80666608 80677608 80688608 80699608 80800808 80811808 80822808 80833808 80844808 80855808
 9: 95311359 95400459 95499459 95588559 95677659 95766759 95855859 95944959 96033069 96122169 96211269 96300369 96399369 96488469 96577569

Last 10 of the first 1000 binned-by-last digit gapful numbers >= 100
 1: 17799771 17800871 17811871 17822871 17833871 17844871 17855871 17866871 17877871 17888871
 2: 27799772 27800872 27811872 27822872 27833872 27844872 27855872 27866872 27877872 27888872
 3: 3084004803 3084334803 3084664803 3084994803 3085225803 3085555803 3085885803 3086116803 3086446803 3086776803
 4: 482282284 482414284 482535284 482656284 482777284 482898284 482909284 483020384 483141384 483262384
 5: 57800875 57811875 57822875 57833875 57844875 57855875 57866875 57877875 57888875 57899875
 6: 6084004806 6084334806 6084664806 6084994806 6085225806 6085555806 6085885806 6086116806 6086446806 6086776806
 7: 7452992547 7453223547 7453993547 7454224547 7454994547 7455225547 7455995547 7456226547 7456996547 7457227547
 8: 8085995808 8086006808 8086116808 8086226808 8086336808 8086446808 8086556808 8086666808 8086776808 8086886808
 9: 9675005769 9675995769 9676886769 9677777769 9678668769 9679559769 9680440869 9681331869 9682222869 9683113869

Functional[edit]

'''Palindromic gapful numbers'''
 
from itertools import chain, count, islice, tee
from functools import reduce
 
 
# palindromicGapfuls :: () -> [Int]
def palindromicGapfuls():
'''A non-finite series of gapful palindromic numbers.
'''

return filter(
lambda n: 0 == n % (int(str(n)[0]) * 10 + (n % 10)),
mergeInOrder(
map(derivedPalindrome(False), count(10))
)(map(derivedPalindrome(True), count(10)))
)
 
 
# derivedPalindrome :: Bool -> Int -> String
def derivedPalindrome(digitsEven):
'''A palindrome of an even or odd number of digits,
obtained by appending either all or just the tail
of the reversed digits of n.
'''

def go(x):
s = str(x)
r = s[::-1]
return int((s + r) if digitsEven else (s + r[1:]))
return lambda n: go(n)
 
 
# --------------------------TESTS--------------------------
# main :: IO ()
def main():
'''Various samples of gapful palindromes grouped by final digit.'''
 
tpl = tee(palindromicGapfuls(), 9)
 
# sample :: (String, Int, Int) -> String
def sample(label, dropped, taken):
return fTable(label)(compose(cons(' '), str))(
compose(unwords, map_(str))
)(
compose(
take(taken),
drop(dropped),
lambda i: filter(
lambda x: i == x % 10,
tpl[i - 1]
)
)
)(enumFromTo(1)(9))
 
print(
'\n\n'.join(map(lambda x: sample(*x), [
('First 20 samples of gapful palindromes ' +
'(> 100) by last digit:', 0, 20),
 
('Last 15 of first 100 gapful palindromes ' +
'(> 100) by last digit:', 65, 15),
 
('Last 10 of first 1000 gapful palindromes ' +
'(> 100) by last digit:', 890, 10)
]))
)
 
# ------------------------DISPLAY -------------------------
 
 
# fTable :: String -> (a -> String) ->
# (b -> String) -> (a -> b) -> [a] -> String
def fTable(s):
'''Heading -> x display function -> fx display function ->
f -> xs -> tabular string.
'''

def go(xShow, fxShow, f, xs):
ys = [xShow(x) for x in xs]
w = max(map(len, ys))
return s + '\n' + '\n'.join(map(
lambda x, y: y.rjust(w, ' ') + ': ' + fxShow(f(x)),
xs, ys
))
return lambda xShow: lambda fxShow: lambda f: lambda xs: go(
xShow, fxShow, f, xs
)
 
 
# ------------------------GENERIC--------------------------
 
# Just :: a -> Maybe a
def Just(x):
'''Constructor for an inhabited Maybe (option type) value.
Wrapper containing the result of a computation.
'''

return {'type': 'Maybe', 'Nothing': False, 'Just': x}
 
 
# Nothing :: Maybe a
def Nothing():
'''Constructor for an empty Maybe (option type) value.
Empty wrapper returned where a computation is not possible.
'''

return {'type': 'Maybe', 'Nothing': True}
 
 
# compose :: ((a -> a), ...) -> (a -> a)
def compose(*fs):
'''Composition, from right to left,
of a series of functions.
'''

return lambda x: reduce(
lambda a, f: f(a),
fs[::-1], x
)
 
 
# cons :: a -> [a] -> [a]
def cons(x):
'''A list string or iterator constructed
from x as head, and xs as tail.
'''

return lambda xs: [x] + xs if (
isinstance(xs, list)
) else x + xs if (
isinstance(xs, str)
) else chain([x], xs)
 
 
# drop :: Int -> [a] -> [a]
def drop(n):
'''The sublist of xs beginning at
(zero-based) index n.
'''

def go(xs):
take(n)(xs)
return xs
return lambda xs: go(xs)
 
 
# enumFromTo :: Int -> Int -> [Int]
def enumFromTo(m):
'''Enumeration of integer values [m..n]'''
def go(n):
return list(range(m, 1 + n))
return lambda n: go(n)
 
 
# map :: (a -> b) -> [a] -> [b]
def map_(f):
'''The list obtained by applying f
to each element of xs.
'''

return lambda xs: [f(x) for x in xs]
 
 
# mergeInOrder :: Gen [Int] -> Gen [Int] -> Gen [Int]
def mergeInOrder(ga):
'''An ordered, non-finite, stream of integers
obtained by merging two other such streams.
'''

def go(ma, mb):
a = ma
b = mb
while not a['Nothing'] and not b['Nothing']:
(a1, a2) = a['Just']
(b1, b2) = b['Just']
if a1 < b1:
yield a1
a = uncons(a2)
else:
yield b1
b = uncons(b2)
 
return lambda gb: go(uncons(ga), uncons(gb))
 
 
# take :: Int -> [a] -> [a]
def take(n):
'''The prefix of xs of length n,
or xs itself if n > length xs.
'''

return lambda xs: list(islice(xs, n))
 
 
# uncons :: [a] -> Maybe (a, [a])
def uncons(xs):
'''The deconstruction of a non-empty list
(or generator stream) into two parts:
a head value, and the remaining values.
'''

nxt = take(1)(xs)
return Just((nxt[0], xs)) if nxt else Nothing()
 
 
# unwords :: [String] -> String
def unwords(xs):
'''A space-separated string derived
from a list of words.
'''

return ' '.join(xs)
 
 
# MAIN ---
if __name__ == '__main__':
main()
Output:
First 20 samples of gapful palindromes (> 100) by last digit:
 1: 121 1001 1111 1221 1331 1441 1551 1661 1771 1881 1991 10901 11011 12221 13431 14641 15851 17171 18381 19591
 2: 242 2002 2112 2222 2332 2442 2552 2662 2772 2882 2992 20702 21912 22022 23232 24442 25652 26862 28182 29392
 3: 363 3003 3333 3663 3993 31713 33033 36663 300003 303303 306603 309903 312213 315513 318813 321123 324423 327723 330033 333333
 4: 484 4004 4224 4444 4664 4884 40304 42724 44044 46464 48884 400004 401104 402204 403304 404404 405504 406604 407704 408804
 5: 5005 5115 5225 5335 5445 5555 5665 5775 5885 5995 50105 51315 52525 53735 54945 55055 56265 57475 58685 59895
 6: 6006 6336 6666 6996 61116 64746 66066 69696 600006 603306 606606 609906 612216 615516 618816 621126 624426 627726 630036 633336
 7: 7007 7777 77077 700007 707707 710017 717717 720027 727727 730037 737737 740047 747747 750057 757757 760067 767767 770077 777777 780087
 8: 8008 8448 8888 80608 86768 88088 800008 802208 804408 806608 808808 821128 823328 825528 827728 829928 840048 842248 844448 846648
 9: 9009 9999 94149 99099 900009 909909 918819 927729 936639 945549 954459 963369 972279 981189 990099 999999 9459549 9508059 9557559 9606069

Last 15 of first 100 gapful palindromes (> 100) by last digit:
 1: 165561 166661 167761 168861 169961 170071 171171 172271 173371 174471 175571 176671 177771 178871 179971
 2: 265562 266662 267762 268862 269962 270072 271172 272272 273372 274472 275572 276672 277772 278872 279972
 3: 30366303 30399303 30422403 30455403 30488403 30511503 30544503 30577503 30600603 30633603 30666603 30699603 30722703 30755703 30788703
 4: 4473744 4485844 4497944 4607064 4619164 4620264 4632364 4644464 4656564 4668664 4681864 4693964 4803084 4815184 4827284
 5: 565565 566665 567765 568865 569965 570075 571175 572275 573375 574475 575575 576675 577775 578875 579975
 6: 60399306 60422406 60455406 60488406 60511506 60544506 60577506 60600606 60633606 60666606 60699606 60722706 60755706 60788706 60811806
 7: 72299227 72322327 72399327 72422427 72499427 72522527 72599527 72622627 72699627 72722727 72799727 72822827 72899827 72922927 72999927
 8: 80611608 80622608 80633608 80644608 80655608 80666608 80677608 80688608 80699608 80800808 80811808 80822808 80833808 80844808 80855808
 9: 95311359 95400459 95499459 95588559 95677659 95766759 95855859 95944959 96033069 96122169 96211269 96300369 96399369 96488469 96577569

Last 10 of first 1000 gapful palindromes (> 100) by last digit:
 1: 17799771 17800871 17811871 17822871 17833871 17844871 17855871 17866871 17877871 17888871
 2: 27799772 27800872 27811872 27822872 27833872 27844872 27855872 27866872 27877872 27888872
 3: 3084004803 3084334803 3084664803 3084994803 3085225803 3085555803 3085885803 3086116803 3086446803 3086776803
 4: 482282284 482414284 482535284 482656284 482777284 482898284 482909284 483020384 483141384 483262384
 5: 57800875 57811875 57822875 57833875 57844875 57855875 57866875 57877875 57888875 57899875
 6: 6084004806 6084334806 6084664806 6084994806 6085225806 6085555806 6085885806 6086116806 6086446806 6086776806
 7: 7452992547 7453223547 7453993547 7454224547 7454994547 7455225547 7455995547 7456226547 7456996547 7457227547
 8: 8085995808 8086006808 8086116808 8086226808 8086336808 8086446808 8086556808 8086666808 8086776808 8086886808
 9: 9675005769 9675995769 9676886769 9677777769 9678668769 9679559769 9680440869 9681331869 9682222869 9683113869

REXX[edit]

/*REXX program computes and displays palindromic gapful numbers, it also can show those */
/*─────────────────────── palindromic gapful numbers listed by their last decimal digit.*/
numeric digits 20 /*ensure enough decimal digits gapfuls.*/
parse arg pangaps
if pangaps='' then pangaps= 20 100@@15 1000@@10 /*assume some ranges*/
 
do until pangaps=''; parse var pangaps stuff pangaps; call pangap stuff
end /*until*/
exit /*stick a fork in it, we're all done. */
/*──────────────────────────────────────────────────────────────────────────────────────*/
pangap: procedure; parse arg n '@' sp '@' z; #= 0; if sp=='' then sp= 100
if z=='' then z= n
@which= ' last '; if z==n then @which= " first "
@pangap#Start= ' palindromic gapful numbers starting at: '
say center(@which z " of " n @pangap#Start sp" ", 140, "~")
#.= 0 /*array of result counts for each digit*/
tot= n * 9 /*total # of results that are wanted. */
$.=; sum= 0 /*blank lists; digit results (so far).*/
do j=sp until sum==tot /*loop 'til all digit counters filled. */
parse var j a 2 '' -1 b /*obtain the first and last dec. digit.*/
if a \==b then iterate /*Not a palindrome? Then skip it.*/
if #.b ==n then iterate /*Digit quota filled? " " " */
if reverse(j) \==j then iterate /*Not a palindrome? " " " */
if j // (a||b) \==0 then iterate /*Not divisible by A||B? " " " */
sum= sum + 1; #.b= #.b + 1; /*bump the sum counter & digit counter.*/
$.b= $.b j /*append J to the correct list. */
end /*j*/
/* [↓] just show the last Z numbers.*/
do k=1 for 9; say k':' strip( subword($.k, 1 + n - z) )
end /*k*/; say; return
output   when using the internal default inputs:

(Shown at   5/6   size.)

═════════════════════════════════════ first  20  of  20  palindromic gapful numbers starting at:  100 ══════════════════════════════════════
1: 121 1001 1111 1221 1331 1441 1551 1661 1771 1881 1991 10901 11011 12221 13431 14641 15851 17171 18381 19591
2: 242 2002 2112 2222 2332 2442 2552 2662 2772 2882 2992 20702 21912 22022 23232 24442 25652 26862 28182 29392
3: 363 3003 3333 3663 3993 31713 33033 36663 300003 303303 306603 309903 312213 315513 318813 321123 324423 327723 330033 333333
4: 484 4004 4224 4444 4664 4884 40304 42724 44044 46464 48884 400004 401104 402204 403304 404404 405504 406604 407704 408804
5: 5005 5115 5225 5335 5445 5555 5665 5775 5885 5995 50105 51315 52525 53735 54945 55055 56265 57475 58685 59895
6: 6006 6336 6666 6996 61116 64746 66066 69696 600006 603306 606606 609906 612216 615516 618816 621126 624426 627726 630036 633336
7: 7007 7777 77077 700007 707707 710017 717717 720027 727727 730037 737737 740047 747747 750057 757757 760067 767767 770077 777777 780087
8: 8008 8448 8888 80608 86768 88088 800008 802208 804408 806608 808808 821128 823328 825528 827728 829928 840048 842248 844448 846648
9: 9009 9999 94149 99099 900009 909909 918819 927729 936639 945549 954459 963369 972279 981189 990099 999999 9459549 9508059 9557559 9606069

═════════════════════════════════════ last  15  of  100  palindromic gapful numbers starting at:  100 ══════════════════════════════════════
1: 165561 166661 167761 168861 169961 170071 171171 172271 173371 174471 175571 176671 177771 178871 179971
2: 265562 266662 267762 268862 269962 270072 271172 272272 273372 274472 275572 276672 277772 278872 279972
3: 30366303 30399303 30422403 30455403 30488403 30511503 30544503 30577503 30600603 30633603 30666603 30699603 30722703 30755703 30788703
4: 4473744 4485844 4497944 4607064 4619164 4620264 4632364 4644464 4656564 4668664 4681864 4693964 4803084 4815184 4827284
5: 565565 566665 567765 568865 569965 570075 571175 572275 573375 574475 575575 576675 577775 578875 579975
6: 60399306 60422406 60455406 60488406 60511506 60544506 60577506 60600606 60633606 60666606 60699606 60722706 60755706 60788706 60811806
7: 72299227 72322327 72399327 72422427 72499427 72522527 72599527 72622627 72699627 72722727 72799727 72822827 72899827 72922927 72999927
8: 80611608 80622608 80633608 80644608 80655608 80666608 80677608 80688608 80699608 80800808 80811808 80822808 80833808 80844808 80855808
9: 95311359 95400459 95499459 95588559 95677659 95766759 95855859 95944959 96033069 96122169 96211269 96300369 96399369 96488469 96577569

═════════════════════════════════════ last  10  of  1000  palindromic gapful numbers starting at:  100 ═════════════════════════════════════
1: 17799771 17800871 17811871 17822871 17833871 17844871 17855871 17866871 17877871 17888871
2: 27799772 27800872 27811872 27822872 27833872 27844872 27855872 27866872 27877872 27888872
3: 3084004803 3084334803 3084664803 3084994803 3085225803 3085555803 3085885803 3086116803 3086446803 3086776803
4: 482282284 482414284 482535284 482656284 482777284 482898284 482909284 483020384 483141384 483262384
5: 57800875 57811875 57822875 57833875 57844875 57855875 57866875 57877875 57888875 57899875
6: 6084004806 6084334806 6084664806 6084994806 6085225806 6085555806 6085885806 6086116806 6086446806 6086776806
7: 7452992547 7453223547 7453993547 7454224547 7454994547 7455225547 7455995547 7456226547 7456996547 7457227547
8: 8085995808 8086006808 8086116808 8086226808 8086336808 8086446808 8086556808 8086666808 8086776808 8086886808
9: 9675005769 9675995769 9676886769 9677777769 9678668769 9679559769 9680440869 9681331869 9682222869 9683113869

zkl[edit]

Using ideas from the Factor entry

// 10,True  --> 101,111,121,131,141,151,161,171,181,191,202, ..
// 10,False --> 1001,1111,1221,1331,1441,1551,1661,1771,1881,..
fcn createPalindromeW(start,oddLength){ //--> iterator
[start..].tweak('wrap(z){
p,n := z,z;
if(oddLength) n/=10;
while(n>0){ p,n = p*10 + (n%10), n/10; }
p
})
}
fcn palindromicGapfulW(endsWith){ //--> iterator
po,pe := createPalindromeW(10,True), createPalindromeW(10,False);
div:=endsWith*10 + endsWith;
Walker.zero().tweak('wrap{
p:=( if(pe.peek()<po.peek()) pe.next() else po.next() );
if(p%10==endsWith and (p%div)==0) p else Void.Skip
})
}
println("First 20 palindromic gapful numbers:");
[1..9].apply(palindromicGapfulW).apply("walk",20) : pgpp(_);
 
foreach N,sz in (T( T(100,15), T(1_000,10), )){
println("\nLast %d of %,d palindromic gapful numbers:".fmt(sz,N));
[1..9].apply('wrap(n){ palindromicGapfulW(n).drop(N-sz).walk(sz) }) : pgpp(_);
}
 
fcn pgpp(table){ // pretty print ( (numbers),(numbers) )
m,fmt := (0).max(table.apply((0).max)).numDigits, "%%%dd ".fmt(m).fmt;
foreach d,row in ([1..].zip(table)){ println(d,": ",row.pump(String,fmt)) }
}
Output:
First 20 palindromic gapful numbers:
1:     121    1001    1111    1221    1331    1441    1551    1661    1771    1881    1991   10901   11011   12221   13431   14641   15851   17171   18381   19591 
2:     242    2002    2112    2222    2332    2442    2552    2662    2772    2882    2992   20702   21912   22022   23232   24442   25652   26862   28182   29392 
3:     363    3003    3333    3663    3993   31713   33033   36663  300003  303303  306603  309903  312213  315513  318813  321123  324423  327723  330033  333333 
4:     484    4004    4224    4444    4664    4884   40304   42724   44044   46464   48884  400004  401104  402204  403304  404404  405504  406604  407704  408804 
5:    5005    5115    5225    5335    5445    5555    5665    5775    5885    5995   50105   51315   52525   53735   54945   55055   56265   57475   58685   59895 
6:    6006    6336    6666    6996   61116   64746   66066   69696  600006  603306  606606  609906  612216  615516  618816  621126  624426  627726  630036  633336 
7:    7007    7777   77077  700007  707707  710017  717717  720027  727727  730037  737737  740047  747747  750057  757757  760067  767767  770077  777777  780087 
8:    8008    8448    8888   80608   86768   88088  800008  802208  804408  806608  808808  821128  823328  825528  827728  829928  840048  842248  844448  846648 
9:    9009    9999   94149   99099  900009  909909  918819  927729  936639  945549  954459  963369  972279  981189  990099  999999 9459549 9508059 9557559 9606069 

Last 15 of 100 palindromic gapful numbers:
1:   165561   166661   167761   168861   169961   170071   171171   172271   173371   174471   175571   176671   177771   178871   179971 
2:   265562   266662   267762   268862   269962   270072   271172   272272   273372   274472   275572   276672   277772   278872   279972 
3: 30366303 30399303 30422403 30455403 30488403 30511503 30544503 30577503 30600603 30633603 30666603 30699603 30722703 30755703 30788703 
4:  4473744  4485844  4497944  4607064  4619164  4620264  4632364  4644464  4656564  4668664  4681864  4693964  4803084  4815184  4827284 
5:   565565   566665   567765   568865   569965   570075   571175   572275   573375   574475   575575   576675   577775   578875   579975 
6: 60399306 60422406 60455406 60488406 60511506 60544506 60577506 60600606 60633606 60666606 60699606 60722706 60755706 60788706 60811806 
7: 72299227 72322327 72399327 72422427 72499427 72522527 72599527 72622627 72699627 72722727 72799727 72822827 72899827 72922927 72999927 
8: 80611608 80622608 80633608 80644608 80655608 80666608 80677608 80688608 80699608 80800808 80811808 80822808 80833808 80844808 80855808 
9: 95311359 95400459 95499459 95588559 95677659 95766759 95855859 95944959 96033069 96122169 96211269 96300369 96399369 96488469 96577569 

Last 10 of 1,000 palindromic gapful numbers:
1:   17799771   17800871   17811871   17822871   17833871   17844871   17855871   17866871   17877871   17888871 
2:   27799772   27800872   27811872   27822872   27833872   27844872   27855872   27866872   27877872   27888872 
3: 3084004803 3084334803 3084664803 3084994803 3085225803 3085555803 3085885803 3086116803 3086446803 3086776803 
4:  482282284  482414284  482535284  482656284  482777284  482898284  482909284  483020384  483141384  483262384 
5:   57800875   57811875   57822875   57833875   57844875   57855875   57866875   57877875   57888875   57899875 
6: 6084004806 6084334806 6084664806 6084994806 6085225806 6085555806 6085885806 6086116806 6086446806 6086776806 
7: 7452992547 7453223547 7453993547 7454224547 7454994547 7455225547 7455995547 7456226547 7456996547 7457227547 
8: 8085995808 8086006808 8086116808 8086226808 8086336808 8086446808 8086556808 8086666808 8086776808 8086886808 
9: 9675005769 9675995769 9676886769 9677777769 9678668769 9679559769 9680440869 9681331869 9682222869 9683113869 
/* We can also thread the whole mess, which for this case, is a 3.75 speed up
* (3 min to 48sec) with 8 cores (Intel 4/4).
*/
fcn palGT(n,N,sz){ palindromicGapfulW(n).drop(N-sz).walk(sz) } // worker thread
foreach N,sz in (T( T(100_000,1) )){
println("\nLast %d of %,d palindromic gapful numbers:".fmt(sz,N));
[1..9].apply('wrap(n){ palGT.future(n,N,sz) }) // create threads
.apply("noop") // wait for threads to finish
 : pgpp(_);
}
Output:
Last 1 of 100,000 palindromic gapful numbers:
1:   178788887871 
2:   278788887872 
3: 30878611687803 
4:  4833326233384 
5:   578789987875 
6: 60878611687806 
7: 74826144162847 
8: 80869688696808 
9: 96878077087869