#!/usr/bin/perl use warnings; use strict; my $n = <>; # read the input my $r = ''; my $p = 2; while ($n > 1) { if ($n % $p == 0) { $r .= "$p, "; # . is the concatenation operator $n /= $p; } else { ++$p; } } print "$r\n";