Skip to content

Commit b5fd7f5

Browse files
committed
Some optimizations.
1 parent f07c780 commit b5fd7f5

File tree

1 file changed

+3
-7
lines changed

1 file changed

+3
-7
lines changed

categories/euler/prob601-shlomif.p6

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,17 +16,13 @@ L<http://projecteuler.net/problem=601>
1616
sub calc_P($s, $N)
1717
{
1818
my $l = [lcm] 1 .. $s;
19-
my $i = $l;
19+
my $i = 0;
2020
my $ret = 0;
2121
my $t = $s + 1;
2222
my $M = $N - 1;
23-
while $i < $M
23+
while (($i = $i + $l) < $M)
2424
{
25-
if $i % $t
26-
{
27-
++$ret;
28-
}
29-
$i += $l;
25+
++$ret if $i % $t;
3026
}
3127
return $ret;
3228
}

0 commit comments

Comments
 (0)