# Digit fifth powers

```ruby
func digit_nth_powers(n, base=10) {
 
    var D = @(^base)
    var P = D.map {|d| d**n }
    var A = []
    var m = (base-1)**n
 
    for(var (k, t) = (1, 1); k*m >= t; (++k, t*=base)) {
        D.combinations_with_repetition(k, {|*c|
            var v = c.sum {|d| P[d] }
            A.push(v) if (v.digits(base).sort == c)
        })
    }
 
    A.sort.grep { _ > 1 }
}
 
for n in (3..8) {
    var a = digit_nth_powers(n)
    say "Sum of #{n}-th powers of their digits: #{a.join(' + ')} = #{a.sum}"
}
```

#### Output:

```
Sum of 3-th powers of their digits: 153 + 370 + 371 + 407 = 1301
Sum of 4-th powers of their digits: 1634 + 8208 + 9474 = 19316
Sum of 5-th powers of their digits: 4150 + 4151 + 54748 + 92727 + 93084 + 194979 = 443839
Sum of 6-th powers of their digits: 548834 = 548834
Sum of 7-th powers of their digits: 1741725 + 4210818 + 9800817 + 9926315 + 14459929 = 40139604
Sum of 8-th powers of their digits: 24678050 + 24678051 + 88593477 = 137949578
```


---

# 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/d/digit_fifth_powers.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.
