#!/usr/bin/env perl use strict; use warnings; my $nn = <>; chomp $nn; my %h; my $n = 10 ** $nn; for (my $i = 1; $i * $i <= $n; $i++) { if ($n % $i == 0) { $h{$i} = $h{$n/$i} = 1; } } my @vs; while (my ($k, $v) = each(%h)) { push @vs, $k; } @vs = sort {$a <=> $b} @vs; for my $v (@vs) { print "$v\n"; }