aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Hamlin <1197072+myrrhlin@users.noreply.github.com>2019-07-18 09:20:58 -0400
committerMichael Hamlin <1197072+myrrhlin@users.noreply.github.com>2019-07-18 10:27:12 -0400
commit7f1a486a41d2de4343b423091644d163f5a4a218 (patch)
tree72fc352cb36a7e10bec55de43bef014abcbe8272
parent8d9de0e82ebe13b4a1a89cb59a7da4730ad06651 (diff)
downloadperlweeklychallenge-club-7f1a486a41d2de4343b423091644d163f5a4a218.tar.gz
perlweeklychallenge-club-7f1a486a41d2de4343b423091644d163f5a4a218.tar.bz2
perlweeklychallenge-club-7f1a486a41d2de4343b423091644d163f5a4a218.zip
use bitshift instead of exponentation
-rw-r--r--challenge-017/michael-hamlin/perl5/t1-ackermann-two.pl4
1 files changed, 2 insertions, 2 deletions
diff --git a/challenge-017/michael-hamlin/perl5/t1-ackermann-two.pl b/challenge-017/michael-hamlin/perl5/t1-ackermann-two.pl
index 8fc4ca80a0..0424ac782b 100644
--- a/challenge-017/michael-hamlin/perl5/t1-ackermann-two.pl
+++ b/challenge-017/michael-hamlin/perl5/t1-ackermann-two.pl
@@ -56,10 +56,10 @@ sub _twohyper( $n, $b ) {
# result is just 2
} elsif ($n == 3) {
# exponentiation is iterated multiplication
- $result **= $b;
+ $result = 1 << $b; # 2 ** $b
} elsif ($n == 4) {
# tetration is iterated exponentiation
- for (2 .. $b) { $result = 2 ** $result }
+ for (2 .. $b) { $result = 1 << $result } # 2 ** $result
} else {
# $n > 4 means iterated hyper...
$result = _twohyper( $n - 1, 2 );