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.


with javascript_semantics 
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

function digit(sequence results, integer d)
    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
                    if count==mx then return results 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...
    return results
end function

procedure main()
    sequence results = repeat(repeat({},9),mx)
    for d=1 to 9 do -- (the start/end digit)
        results = digit(results,d)
    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()
