# Next special primes

```ruby
func special_primes(upto) {

    var gap  = 0
    var prev = 2
    var list = [[prev, gap]]

    loop {
        var n = prev+gap
        n = n.next_prime
        break if (n > upto)
        gap = n-prev
        list << [n, gap]
        prev = n
    }

    return list
}

special_primes(1050).each_2d {|p,gap|
    say "#{'%4s' % p} #{'%4s' % gap}"
}
```

## Output:

```
   2    0
   3    1
   5    2
  11    6
  19    8
  29   10
  41   12
  59   18
  79   20
 101   22
 127   26
 157   30
 191   34
 227   36
 269   42
 313   44
 359   46
 409   50
 461   52
 521   60
 587   66
 659   72
 733   74
 809   76
 887   78
 967   80
1049   82
```


---

# 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/n/next_special_primes.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.
