Pairs with common factors: Difference between revisions
Content added Content deleted
Thundergnat (talk | contribs) m (extend stretch goal) |
Thundergnat (talk | contribs) m (→{{header|Raku}}: if we aren't reifying, pointless to have the intermediates) |
||
Line 56: | Line 56: | ||
sub pair-count (\n) { n × (n - 1) / 2 + 1 - sum (1..n).map: { 𝜑[$_] } } |
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" |
say "Number of pairs with common factors - first one hundred terms:\n" |
||
~ |
~ (1..100).map(&pair-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> |
for ^7 { say (my $i = 10 ** $_).&ordinal.tc.fmt("%22s term: ") ~ $i.&pair-count.&comma }</lang> |