Skip to content

Commit a1dabfb

Browse files
committed
optimize euler prob 288
Lower to native ints. 4x speed improvement.
1 parent 33124d6 commit a1dabfb

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

categories/euler/prob288-shlomif.p6

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,22 +38,22 @@ sub factorial_factor_exp($n , $f)
3838
}
3939

4040
sub MAIN(:$verbose = False) {
41-
my @t_n;
41+
my int @t_n;
4242

4343
my $N_LIM = 10;
44-
my $BASE = 61;
44+
my int $BASE = 61;
4545
my $LIM = 10_000_000;
4646

4747
my $S_0 = 290797;
48-
my $s = $S_0;
48+
my int $s = $S_0;
4949

5050
for (0 .. $N_LIM-1) -> $n {
5151
@t_n.push($s % $BASE);
5252
$s = (($s * $s) % 50515093);
5353
}
5454

55-
my $sum = 0;
56-
for ($N_LIM .. $LIM) -> $n {
55+
my int $sum = 0;
56+
for ($N_LIM .. $LIM) -> int $n {
5757
if $n % 10_000 == 0 {
5858
say "Reached $n" if $verbose;
5959
}

0 commit comments

Comments
 (0)