> For the complete documentation index, see [llms.txt](https://trizen.gitbook.io/sidef-lang/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://trizen.gitbook.io/sidef-lang/programming_tasks/g/gapful_numbers.md).

# Gapful numbers

Concept extended to other bases:

```ruby
func is_gapful(n, base=10) {
    n.is_div(base*floor(n / base**n.ilog(base)) + n%base)
}

var task = [
    "(Required) The first %s gapful numbers (>= %s)", 30, 1e2, 10,
    "(Required) The first %s gapful numbers (>= %s)", 15, 1e6, 10,
    "(Required) The first %s gapful numbers (>= %s)", 10, 1e9, 10,
    "(Extra) The first %s gapful numbers (>= %s)", 10, 987654321, 10,
    "(Extra) The first %s gapful numbers (>= %s)", 10, 987654321, 12,
]

task.each_slice(4, {|title, n, from, b|
    say sprintf("\n#{title} for base #{b}:", n, from.commify)
    say (from..Inf -> lazy.grep{ is_gapful(_,b) }.first(n).join(' '))
})
```

## Output:

```
(Required) The first 30 gapful numbers (>= 100) for base 10:
100 105 108 110 120 121 130 132 135 140 143 150 154 160 165 170 176 180 187 190 192 195 198 200 220 225 231 240 242 253

(Required) The first 15 gapful numbers (>= 1,000,000) for base 10:
1000000 1000005 1000008 1000010 1000016 1000020 1000021 1000030 1000032 1000034 1000035 1000040 1000050 1000060 1000065

(Required) The first 10 gapful numbers (>= 1,000,000,000) for base 10:
1000000000 1000000001 1000000005 1000000008 1000000010 1000000016 1000000020 1000000027 1000000030 1000000032

(Extra) The first 10 gapful numbers (>= 987,654,321) for base 10:
987654330 987654334 987654336 987654388 987654420 987654485 987654510 987654513 987654592 987654600

(Extra) The first 10 gapful numbers (>= 987,654,321) for base 12:
987654325 987654330 987654336 987654360 987654368 987654384 987654388 987654390 987654393 987654395
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://trizen.gitbook.io/sidef-lang/programming_tasks/g/gapful_numbers.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
