#!/usr/bin/perl use warnings; my ($x, $n)=@ARGV; my $p=1; $p*=$x while $n--; print "$p\n";
#!/usr/bin/perl use warnings; sub power { my ($x, $n)=@_; return 1 if $n==0; return $x if $n==1; return $x*power($x*$x, ($n-1)/2) if $n % 2; return power($x*$x, $n/2); } print power(@ARGV), "\n";
#!/usr/bin/perl use warnings; my ($x, $n)=@ARGV; my $p=1; while($n) { if($n % 2) { $p*=$x; $n--; } $n/=2; $x*=$x; } print "$p\n";