Twin primes: Difference between revisions

(promote)
Line 887:
return true
}</lang>
 
=={{header|Mathematica}}/{{header|Wolfram Language}}==
<lang Mathematica>ClearAll[TwinPrimeCount]
TwinPrimeCount[mx_] := Module[{pmax, min, max, total},
pmax = PrimePi[mx];
total = 0;
Do[
min = 10^6 i;
min = Max[min, 1];
max = 10^6 (i + 1);
max = Min[max, pmax];
total += Count[Differences[Prime[Range[min, max]]], 2]
,
{i, 0, Ceiling[pmax/10^6]}
];
total
]
Do[Print[{10^i, TwinPrimeCount[10^i]}], {i, 9}]</lang>
{{out}}
<pre>{10,2}
{100,8}
{1000,35}
{10000,205}
{100000,1224}
{1000000,8169}
{10000000,58980}
{100000000,440312}
{1000000000,3424506}</pre>
 
=={{header|Nim}}==
1,111

edits