# Sum of the digits of n is substring of n

```ruby
var upto = 1000
var base = 10

var list = (^upto -> grep {
    .digits(base).contains(.sumdigits(base).digits(base)...)
})

say "Numbers under #{upto} whose sum of digits is a substring of themselves:"

list.each_slice(8, {|*a|
    say a.map { '%3s' % _ }.join(' ')
})

say "\n#{list.len} such numbers found."
```

## Output:

```
Numbers under 1000 whose sum of digits is a substring of themselves:
  0   1   2   3   4   5   6   7
  8   9  10  20  30  40  50  60
 70  80  90 100 109 119 129 139
149 159 169 179 189 199 200 300
400 500 600 700 800 900 910 911
912 913 914 915 916 917 918 919

48 such numbers found.
```


---

# 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/sum_of_the_digits_of_n_is_substring_of_n.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.
