Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Optimisation. Get rid of $total_num .
  • Loading branch information
shlomif committed May 6, 2015
1 parent 0144c93 commit 212eb22
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions categories/euler/prob151-shlomif.p6
@@ -1,6 +1,5 @@
use v6;

my $total_num = 0;
my $sum = 0;

# rec is short for "recurse".
Expand All @@ -11,7 +10,6 @@ sub rec($factor, @counts, $result)
if $cnt == 0
{
$sum += $factor * $result;
$total_num += $factor;
}
else
{
Expand All @@ -34,4 +32,4 @@ sub rec($factor, @counts, $result)

rec(1,[1],0);

say "Result == ", ($sum / $total_num - 2).fmt("%.6f");
say "Result == ", ($sum - 2).fmt("%.6f");

0 comments on commit 212eb22

Please sign in to comment.