#!/usr/bin/perl -w ############################################# # Find factorization for any input number # # Thomas Bisig (05.2004), thomas@macapp.net # ############################################# $input = ""; $c = 0; @nums = ( 2 , 3 , 5 , 7 , 11 , 13 , 17 ); print "Enter your number: "; chomp( $input = ); for ( $i = 0 ; $i <= 6 ; $i++ ) { $temp = $input; while ( $temp % $nums[$i] == 0 ) { $c += 1; $temp /= $nums[$i]; } if ( $c != 0 ) { print "($nums[$i],$c)\n"; } $c = 0 }