use strict; use warnings; my $verbose = 0; my ($n, $k) = split /[ \n]/, <>; $n -= $k; print "n : $n\n" if ($verbose); my @list = &fact($n); print join ", ", @list, "\n" if ($verbose); print $#list + 2, "\n"; # 0始まりのため+1、当該数値自身も一つなので+1 #### sub fact { my $arg = shift; for my $i (2 .. $arg - 1) { if ($arg % $i == 0) { return $i, &fact($arg / $i); } } return $arg; }