Palindromic 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.


Evenly divisible   means divisible with   no   remainder.



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   4
   the digit   5
   the digit   6
   the digit   7
   the digit   8
   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.



Note

All palindromic gapful numbers are divisible by eleven.



Related tasks

   palindrome detection.
   gapful numbers.


Also see

   The OEIS entry:   A108343 gapful numbers.


function is_gapful( n as uinteger ) as boolean
    if n<100 then return false
    dim as string ns = str(n)
    dim as uinteger gap = 10*val(mid(ns,1,1)) + val(mid(ns,len(ns),1))
    if n mod gap = 0 then return true else return false
end function
 
function is_palindrome( n as uinteger ) as boolean
    dim as string ns = str(n)
    for i as uinteger = 1 to len(ns)\2
        if mid(ns,i,1) <> mid(ns,len(ns)+1-i,1) then return false
    next i
    return true
end function
 
function padto( n as uinteger, s as integer ) as string
    dim as string outstr=""
    dim as integer k = len(str(n))
    for i as integer = 1 to s-k
        outstr = " " + outstr
    next i
    return outstr + str(n)
end function
 
sub print_range( yays() as uinteger, first as uinteger, last as uinteger)
    dim as string outstr
    for i as uinteger = first to last
        outstr = padto(i,4)+"  :  "
        for d as uinteger = 1 to 9
            outstr += padto(yays(d,i), 11)
        next d
        print outstr
    next i
end sub
 
#define is_yay(n) (is_gapful(n) and is_palindrome(n))
#define log10(n) log(n)*0.43429448190325182765112891891660508229
 
dim as uinteger yays(1 to 9, 1 to 1000), nyays(1 to 9), num = 99, fd
do
    num += 1 : fd = val(left(str(num),1))
    if fd = 0 then continue do   'no paligap will have 0 as leading digit
    if nyays(fd) = 1000 then 
        num = (fd+1)*10^int(log10(num))
    end if
    if is_yay(num) then
        nyays(fd) += 1
        yays(fd, nyays(fd)) = num
    end if
    for y as uinteger = 1 to 9
        if nyays(y) < 1000 then  continue do
    next y
    exit do
loop
 
'excessive output requirements for such a simple task
print_range(yays(), 1, 20)
print_range(yays(), 86, 100)
print_range(yays(), 991, 1000)