Find prime n such that reversed n is also prime: Difference between revisions

Line 502:
 
 
=={{header|jq}}==
{{works with|jq}}
'''Works with gojq, the Go implementation of jq'''
 
Using the definition of is_prime at [[Erd%C5%91s-primes#jq]]:
<lang jq># generate a stream of the reversible primes
def reversible_primes:
def r: tostring|explode|reverse|implode|tonumber;
(if . == null then infinite else . end) as $n
| 2, (range(3; $n; 2) | select(is_prime and (r|is_prime)));
 
"Primes under 500 which are also primes when the digits are reversed:",
(500 | reversible_primes)</lang>
{{out}}
<pre>
Primes under 500 which are also primes when the digits are reversed:
2
3
5
7
11
13
17
31
37
71
73
79
97
101
107
113
131
149
151
157
167
179
181
191
199
311
313
337
347
353
359
373
383
389
</pre>
=={{header|Julia}}==
<lang julia>using Primes
2,460

edits