Anonymous user
Miller–Rabin primality test: Difference between revisions
→{{header|C sharp|C#}}
(→{{header|Kotlin}}: Updated example see https://github.com/dkandalov/rosettacode-kotlin for details) |
|||
Line 695:
public static bool IsPrime(int n, int k)
{
if ((n < 2) || (n % 2 == 0)) return (n == 2);
Random r = new Random();
{
int temp = s;
while (temp != n - 1 && mod != 1 && mod != n - 1)
{▼
mod = (mod * mod) % n;▼
if(mod != n - 1 && temp % 2 == 0)▼
{
}
}
}
}</lang>
[https://stackoverflow.com/questions/7860802/miller-rabin-primality-test] Corrections made 6/21/2017
<br><br>
<lang csharp>// Miller-Rabin primality test as an extension method on the BigInteger type.
// Based on the Ruby implementation on this page.
|