# Sub-unit squares

Using the method described in the [OEIS entry](https://oeis.org/A061844), representing **(10^n - 1)/9** as a difference of squares **x^2 - y^2** and checking **x^2** to see if it satisfies the conditions.

```ruby
var N   = 20      # how many terms to compute
var arr = Set(1)

for n in (1..Inf) {
    var r = (10**n - 1)/9
    arr << r.diff_of_squares.map{.head}.map{.sqr.digits}.grep {|d|
        (d[-1] != 1) && d.none{.is_zero} && d.map{.dec}.digits2num.is_square
    }.map{.digits2num}...
    break if (arr.len >= N)
}

arr.sort.first(N).each_kv {|k,n|
    say "#{'%2d' % k+1}: #{n}"
}
```

#### Output:

```
 1: 1
 2: 36
 3: 3136
 4: 24336
 5: 5973136
 6: 71526293136
 7: 318723477136
 8: 264779654424693136
 9: 24987377153764853136
10: 31872399155963477136
11: 58396845218255516736
12: 517177921565478376336
13: 252815272791521979771662766736
14: 518364744896318875336864648336
15: 554692513628187865132829886736
16: 658424734191428581711475835136
17: 672475429414871757619952152336
18: 694688876763154697414122245136
19: 711197579293752874333735845136
20: 975321699545235187287523246336
```


---

# 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/sub-unit_squares.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.
