use warnings; use strict; my @P = qw/2 2 3 5 11 277412413/; @P= sort { $a<=>$b } @P; # sort to be sure my @D = (1); my @D_new = (); my $p_old = 0; for my $p (@P) { if ( $p == $p_old ) { @D_new = map { $_* $p } @D_new; } else { @D_new = map { $_* $p } @D; } push @D,@D_new; $p_old = $p; } @D= sort { $a<=>$b } @D; print "Factors @P\n"; print "Divisors: @D\n"; #### Factors 2 2 3 5 11 277412413 Divisors: 1 2 3 4 5 6 10 11 12 15 20 22 30 33 44 55 60 66 110 132 165 220 330 660 277412413 554824826 832237239 1109649652 1387062065 1664474478 2774124130 3051536543 3328948956 4161186195 5548248260 6103073086 8322372390 9154609629 12206146172 15257682715 16644744780 18309219258 30515365430 36618438516 45773048145 61030730860 91546096290 183092192580