Ramanujan primes/twins: Difference between revisions
Content added Content deleted
m (→{{header|Wren}}: Wren-trait -> Wren-iterate) |
(Added Sidef) |
||
Line 388: | Line 388: | ||
There are 74,973 twins in the first 1,000,000 Ramanujan primes. |
There are 74,973 twins in the first 1,000,000 Ramanujan primes. |
||
2.529 seconds</pre> |
2.529 seconds</pre> |
||
=={{header|Sidef}}== |
|||
{{libheader|ntheory}} |
|||
<syntaxhighlight lang="ruby" line>require('ntheory') |
|||
var rp = %S<ntheory>.ramanujan_primes(%S<ntheory>.nth_ramanujan_prime(1e6)) |
|||
for limit in ([1e5, 1e6]) { |
|||
printf("The %sth Ramanujan prime is %s\n", limit.commify, rp[limit-1].commify) |
|||
printf("There are %s twins in the first %s Ramanujan primes.\n\n", |
|||
^(limit-1) -> count {|i| rp[i+1] == rp[i]+2 }.commify, limit.commify) |
|||
}</syntaxhighlight> |
|||
{{out}} |
|||
<pre>The 100,000th Ramanujan prime is 2,916,539 |
|||
There are 8,732 twins in the first 100,000 Ramanujan primes. |
|||
The 1,000,000th Ramanujan prime is 34,072,993 |
|||
There are 74,973 twins in the first 1,000,000 Ramanujan primes.</pre> |
|||
=={{header|Wren}}== |
=={{header|Wren}}== |