Anonymous user
Carmichael 3 strong pseudoprimes: Difference between revisions
Carmichael 3 strong pseudoprimes (view source)
Revision as of 05:09, 30 December 2012
, 11 years agoShorter D entry
(→{{header|Haskell}}: hlint suggestion: "Redundant bracket") |
(Shorter D entry) |
||
Line 27:
=={{header|D}}==
From the Python entry, with several changes. Imports the third (extensible) D entry of the Sieve of Eratosthenes Task.
<lang d>import std.stdio, std.algorithm, std.range, std.bitmanip
sieve_of_eratosthenes3;
struct Carmichael {
static struct Tri { int x, y, z; }
immutable int p1;
Line 69 ⟶ 39:
}
int opApply(immutable int delegate(in ref
int result;
Line 83 ⟶ 53:
if (IsPrime(p3))
if ((p2 * p3) % (p1 - 1) == 1) {
//
result = dg(triple);
if (result) break;
Line 99 ⟶ 65:
}
}
void main() {
Line 105 ⟶ 70:
if (IsPrime(n))
foreach (const c; Carmichael(n))
writefln("%(%d x %)", [c.tupleof]);
}</lang>
{{out}}
|