Gapful numbers

From Fōrmulæ wiki
Jump to: navigation, search

This page is a solution to the task Gapful numbers in the Rosetta Code, written in Fōrmulæ.

Description (from Rosetta Code)

Numbers (expressed in base ten) that are (evenly) divisible by the number formed by the decimal digits of their 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.


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.


  • Generate and show all sets of numbers (below) on one line (horizontally) with a title
  • 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

Also see:


The following function return whether a given number is gapful:

  • The expression Digits creates a list of the digits of the given number, in any base (by default 10). For example, for the input 123, it reduces to {1, 2, 3}
  • The first subexpression (in the case of a list, an element of it) has the index 1. The last subexpression can be retrieved with the index -1 (-2 is the penultimate element and so on).
  • The expression Divides (shown here as a | b) reduces to True if a divides b, False elsewere.


The following function shows gapful numbers from a given value:


Case 1

Showing the first 30 gapful numbers:


Case 2

Showing the first 15 gapful numbers ≥ 1,000,000


Case 3

Showing the first 10 gapful numbers ≥ 1,000,000,000