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


 
// Create function to calculate gapful number
gapful[num,totalCounter] :=
{
   // Display a line explaining the current calculation.
   println["First $totalCounter gapful numbers over $num:"]
   // Start a counter to compare with the total count.
   counter = 0
   while counter < totalCounter
   {
      numStr = toString[num] // Convert the integer to a string
      gapfulNumStr = left[numStr,1] + right[numStr,1] // Concatenate the first and last character of the number to form a two digit number
      gapfulNumInt = parseInt[gapfulNumStr] // Turn the concatenated string back into an integer.
      // If the concatenated two digit integer divides into the current num variable with no remainder, print it to the list and increase our counter
      if num mod gapfulNumInt == 0
      {
         print[numStr + " "]
         counter = counter + 1
      }
      // Increase the current number for the next cycle.
      num = num + 1
   }
   println[] // Linkbreak
}
 
// Print the first 30 gapful numbers over 100, the top 15 over 1,000,000 and the first 10 over 1,000,000,000.
gapful[100,30]
gapful[1000000,15]
gapful[1000000000,10]
 