> 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/s/strange_unique_prime_triplets.md).

# Strange unique prime triplets

```ruby
for n in (30, 1000) {
    var triplets = []
    combinations(n.primes, 3, {|*a|
        triplets << a if a.sum.is_prime
    })
    if (n == 30) {
        say "Unique prime triplets (p,q,r) <= #{n} such that p+q+r is prime:"
        triplets.slices(6).each{.join(' ').say}
    }
    printf("Found %d strange unique prime triplets up to %s.\n", triplets.len, n)
}
```

#### Output:

```
Unique prime triplets (p,q,r) <= 30 such that p+q+r is prime:
[3, 5, 11] [3, 5, 23] [3, 5, 29] [3, 7, 13] [3, 7, 19] [3, 11, 17]
[3, 11, 23] [3, 11, 29] [3, 17, 23] [5, 7, 11] [5, 7, 17] [5, 7, 19]
[5, 7, 29] [5, 11, 13] [5, 13, 19] [5, 13, 23] [5, 13, 29] [5, 17, 19]
[5, 19, 23] [5, 19, 29] [7, 11, 13] [7, 11, 19] [7, 11, 23] [7, 11, 29]
[7, 13, 17] [7, 13, 23] [7, 17, 19] [7, 17, 23] [7, 17, 29] [7, 23, 29]
[11, 13, 17] [11, 13, 19] [11, 13, 23] [11, 13, 29] [11, 17, 19] [11, 19, 23]
[11, 19, 29] [13, 17, 23] [13, 17, 29] [13, 19, 29] [17, 19, 23] [19, 23, 29]
Found 42 strange unique prime triplets up to 30.
Found 241580 strange unique prime triplets up to 1000.
```


---

# 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/s/strange_unique_prime_triplets.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.
