Pairs with common factors: Difference between revisions

Add Maxima implementation
(Add Mathematica/Wolfram Language implementation)
(Add Maxima implementation)
Line 699:
The 1,000,000th pair with common factors count is 196,035,947,609
</pre>
 
=={{header|Maxima}}==
{{trans|Mathematica}}
<syntaxhighlight lang="Maxima">/* Define the prime counting function (pcf) */
pcf(n) := n*(n - 1)/2 + 1 - sum(totient(i), i, 1, n);
 
/* Print pairs of (n, pcf(n)) for n from 1 to 100 */
for n:1 thru 100 do (
pcf_n : ev(pcf(n), numer),
if mod(n, 20) = 0 then (
printf(true, "~4d~%", pcf_n)
) else (
printf(true, "~4d ", pcf_n)
)
);
 
/* Print the 10^expo-th pair with common factors count */
for expo:1 thru 6 do (
pcf_10expo : ev(pcf(10^expo), numer),
printf(true, "The ~a-th pair with common factors count is ~a~%", 10^expo, pcf_10expo)
);</syntaxhighlight>
 
{{out}}
<pre>
0 0 0 1 1 4 4 7 9 14 14 21 21 28 34 41 41 52 52 63
71 82 82 97 101 114 122 137 137 158 158 173 185 202 212 235 235 254 268 291
291 320 320 343 363 386 386 417 423 452 470 497 497 532 546 577 597 626 626 669
669 700 726 757 773 818 818 853 877 922 922 969 969 1006 1040 1079 1095 1148 1148 1195
1221 1262 1262 1321 1341 1384 1414 1461 1461 1526 1544 1591 1623 1670 1692 1755 1755 1810 1848 1907
The 10-th pair with common factors count is 14
The 100-th pair with common factors count is 1907
The 1000-th pair with common factors count is 195309
The 10000-th pair with common factors count is 19597515
The 100000-th pair with common factors count is 1960299247
The 1000000-th pair with common factors count is 196035947609
</pre>
 
 
=={{header|Nim}}==
337

edits