Achilles numbers: Difference between revisions
m
→{{header|Perl}}: minor simplifications
(→{{header|Wren}}: Tidied and moved totient function to Math library as it's used quite often.) |
m (→{{header|Perl}}: minor simplifications) |
||
Line 2,604:
use feature <say current_sub>;
use experimental 'signatures';
use List::AllUtils <max head
use ntheory <is_square_free
use Math::AnyNum <:overload idiv is_power iroot ipow is_coprime>;
sub table { my $t = shift() * (my $c = 1 + length max @_); (
sub powerful_numbers ($n, $k = 2) {
Line 2,618:
__SUB__->($m * ipow($v, $r), $r - 1);
}
}->(1, 2 * $k - 1);
sort { $a <=> $b } @powerful;
}
my
my @P =
!is_power($_) and push @achilles, $_ and $Ahash{$_}++ for @P;
$Ahash{euler_phi $_} and push @strong, $_ for @achilles;
say "First 50 Achilles numbers:\n" . table 10,
say "First 30 strong Achilles numbers:\n" . table 10, head 30, @strong;
say "Number of Achilles numbers with:\n";
my $c;
$l == length and $c++ for @achilles;
say "$l digits: $c";
}</syntaxhighlight>
|