- or download this
use ntheory qw/:all/;
my $n = 183092192580;
print "Factors: @{[factor($n)]}\n";
print "Divisors: @{[divisors($n)]}\n";
- or download this
sub divisors {
my($n,@factors) = @_;
my %divisors;
...
@d;
}
sub powerset {@_ ? map { $_,[$_[0], @$_] } powerset(@_[1..$#_]) : [];}
- or download this
sub divisors {
my($n,@factors) = @_;
...
my @divisors = sort {$a<=>$b} keys %all_factors;
@divisors;
}
- or download this
sub divisors {
my($n,@factors) = @_;
my $sqrtn = int(sqrt($n));
...
my @d = sort {$a<=>$b} keys %all_factors;
@d, map { $_*$_ == $n ? () : int($n/$_) } reverse @d;
}
- or download this
#!/usr/bin/env perl
use warnings;
use strict;
...
my @d = divisors($n,factor($n));
print "$n @d\n";
}