Circular primes: Difference between revisions

Content added Content deleted
No edit summary
m (→‎{{header|J}}: more concise definition for R (the rest is a bit verbose, but leaving it alone for now))
Line 1,254: Line 1,254:
<syntaxhighlight lang="j">
<syntaxhighlight lang="j">


R=: [: ". 'x' ,~ #&'1'
R=: 10x #. #&1
assert 11111111111111111111111111111111x -: R 32
assert 11111111111111111111111111111111x -: R 32


Line 1,325: Line 1,325:
<pre>
<pre>
Note 'The current Miller-Rabin test implemented in c is insufficient for this task'
Note 'The current Miller-Rabin test implemented in c is insufficient for this task'
R=: ([: ". 'x' ,~ #&'1')&>
R=: 10x #. #&1
(;q:@R)&> 500
(;q:@R)&> 500
|limit error
|limit error
Line 1,334: Line 1,334:
Filter=: (#~`)(`:6)
Filter=: (#~`)(`:6)


R=: ([: ". 'x' ,~ #&'1')&>
R=: 10x #. #&1
(; q:@R)&> (0 ~: 3&|)Filter >: i. 26 NB. factor some repunits
(; q:@R)&> (0 ~: 3&|)Filter >: i. 26 NB. factor some repunits
┌──┬─────────────────────────────────┐
┌──┬─────────────────────────────────┐
Line 1,376: Line 1,376:
NB. R(2) R(19), R(23) are probably prime.
NB. R(2) R(19), R(23) are probably prime.
</pre>
</pre>

=={{header|Java}}==
=={{header|Java}}==
<syntaxhighlight lang="java">import java.math.BigInteger;
<syntaxhighlight lang="java">import java.math.BigInteger;