# Strange numbers

```ruby
func generate_from_prefix(limit, p, base) {

    var seq = [p]

    for d in (base-1 -> primes) {
        for k in ([1, -1]) {
            var r = p[0]+(k*d)
            next if (r < 0)
            next if (r >= base)
            var t = [r, p...]
            if (t.digits2num(base) <= limit) {
                seq << __FUNC__(limit, t, base)...
            }
        }
    }

    return seq
}

func strange_numbers(limit, base = 10, digits = @(^base)) {
    digits.map {|p| generate_from_prefix(limit, [p], base)... }\
          .map {|t| t.digits2num(base) }\
          .sort.uniq
}

strange_numbers(500).grep { _ > 100 }.slices(10).each{
    .join(' ').say
}
```

## Output:

```
130 131 135 136 138 141 142 146 147 149
161 163 164 168 169 181 183 185 186 202
203 205 207 241 242 246 247 249 250 252
253 257 258 270 272 274 275 279 292 294
296 297 302 303 305 307 313 314 316 318
350 352 353 357 358 361 363 364 368 369
381 383 385 386 413 414 416 418 420 424
425 427 429 461 463 464 468 469 470 472
474 475 479 492 494 496 497
```


---

# Agent Instructions: 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:

```
GET https://trizen.gitbook.io/sidef-lang/programming_tasks/s/strange_numbers.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
