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

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 tasks

   Harshad or Niven series.
   palindromic gapful numbers.
   largest number divisible by its digits.


Also see

   The OEIS entry:   A108343 gapful numbers.
   numbersaplenty gapful numbers


        IDENTIFICATION DIVISION.
        PROGRAM-ID. GAPFUL.
 
        DATA DIVISION.
        WORKING-STORAGE SECTION.
        01 COMPUTATION.
            02 N            PIC 9(10).
            02 N-DIGITS     REDEFINES N.
               03 ND        PIC 9 OCCURS 10 TIMES.
            02 DIV-CHECK    PIC 9(10)V9(2).
            02 DIV-PARTS    REDEFINES DIV-CHECK.
               03 DIV-INT   PIC 9(10).
               03 DIV-FRAC  PIC 9(2).
            02 GAP-AMOUNT   PIC 99.
            02 GAP-DSOR     PIC 99.
            02 FIRST-DIGIT  PIC 99.
        01 OUTPUT-FORMAT.
            02 N-OUT        PIC Z(10).
 
        PROCEDURE DIVISION.
        BEGIN.
            DISPLAY "First 30 gapful numbers >= 100:".
            MOVE 100 TO N. MOVE 30 TO GAP-AMOUNT.
            PERFORM CHECK-GAPFUL-NUMBER.
 
            DISPLAY " ".
            DISPLAY "First 15 gapful numbers >= 1000000:".
            MOVE 1000000 TO N. MOVE 15 TO GAP-AMOUNT.
            PERFORM CHECK-GAPFUL-NUMBER.
 
            DISPLAY " ".
            DISPLAY "First 10 gapful numbers >= 1000000000:".
            MOVE 1000000000 TO N. MOVE 10 TO GAP-AMOUNT.
            PERFORM CHECK-GAPFUL-NUMBER.
            STOP RUN.
 
        CHECK-GAPFUL-NUMBER.
            SET FIRST-DIGIT TO 1.
            INSPECT N TALLYING FIRST-DIGIT FOR LEADING '0'.
            COMPUTE GAP-DSOR = ND(FIRST-DIGIT) * 10 + ND(10).
            DIVIDE N BY GAP-DSOR GIVING DIV-CHECK.
            IF DIV-FRAC IS EQUAL TO 0
                MOVE N TO N-OUT
                DISPLAY N-OUT
                SUBTRACT 1 FROM GAP-AMOUNT.
            ADD 1 TO N.
            IF GAP-AMOUNT IS GREATER THAN 0 
                GO TO CHECK-GAPFUL-NUMBER.