Pairs with common factors: Difference between revisions

m
→‎{{header|Raku}}: if we aren't reifying, pointless to have the intermediates
m (extend stretch goal)
m (→‎{{header|Raku}}: if we aren't reifying, pointless to have the intermediates)
Line 56:
 
sub pair-count (\n) { n × (n - 1) / 2 + 1 - sum (1..n).map: { 𝜑[$_] } }
 
my @pairs-with-common-factors = (1..*).map: &pair-count;
 
say "Number of pairs with common factors - first one hundred terms:\n"
~ @pairs(1..100).map(&pair-with-common-factors[^100]count).batch(10)».&comma».fmt("%6s").join("\n") ~ "\n";
 
for ^7 { say (my $i = 10 ** $_).&ordinal.tc.fmt("%22s term: ") ~ $i.&pair-count.&comma }</lang>
10,327

edits