# Palindromic primes

```ruby
func palindromic_primes(upto, base = 10) {
    var list = []
    for (var p = 2; p <= upto; p = p.next_palindrome(base)) {
        list << p if p.is_prime
    }
    return list
}

say palindromic_primes(1000)

for n in (1..10) {
    var count = palindromic_primes(10**n).len
    say "There are #{count} palindromic primes <= 10^#{n}"
}
```

## Output:

```
[2, 3, 5, 7, 11, 101, 131, 151, 181, 191, 313, 353, 373, 383, 727, 757, 787, 797, 919, 929]
There are 4 palindromic primes <= 10^1
There are 5 palindromic primes <= 10^2
There are 20 palindromic primes <= 10^3
There are 20 palindromic primes <= 10^4
There are 113 palindromic primes <= 10^5
There are 113 palindromic primes <= 10^6
There are 781 palindromic primes <= 10^7
There are 781 palindromic primes <= 10^8
There are 5953 palindromic primes <= 10^9
There are 5953 palindromic primes <= 10^10
```


---

# 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/p/palindromic_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.
