Primes whose first and last number is 3: Difference between revisions
Content added Content deleted
(→{{header|ALGOL 68}}: Use ALGOL 68-primes) |
|||
Line 243: | Line 243: | ||
Found 2,251 primes under 1,000,000 which begin and end with 3. |
Found 2,251 primes under 1,000,000 which begin and end with 3. |
||
</pre> |
|||
=={{header|jq}}== |
|||
{{works with|jq}} |
|||
'''Works with gojq, the Go implementation of jq''' |
|||
See e.g. [[Erd%C5%91s-primes#jq]] for a suitable implementation of `is_prime`. |
|||
<lang jq># For the stretch goal: |
|||
def count(s): reduce s as $x (null; .+1); |
|||
def task: |
|||
(3, range(303;394;10), range(3003;3994;10) | select(is_prime)), |
|||
"\nStretch goal: \(count( |
|||
3, |
|||
range(303;394;10), |
|||
range(3003;3994;10), |
|||
range(30003;39994;10), |
|||
range(300003;399994;10) |
|||
| select(is_prime)))" ; |
|||
task</lang> |
|||
{{out}} |
|||
<pre> |
|||
3 |
|||
313 |
|||
353 |
|||
373 |
|||
383 |
|||
3023 |
|||
3083 |
|||
3163 |
|||
3203 |
|||
3253 |
|||
3313 |
|||
3323 |
|||
3343 |
|||
3373 |
|||
3413 |
|||
3433 |
|||
3463 |
|||
3533 |
|||
3583 |
|||
3593 |
|||
3613 |
|||
3623 |
|||
3643 |
|||
3673 |
|||
3733 |
|||
3793 |
|||
3803 |
|||
3823 |
|||
3833 |
|||
3853 |
|||
3863 |
|||
3923 |
|||
3943 |
|||
Stretch goal: 2251 |
|||
</pre> |
</pre> |
||