Pisano period: Difference between revisions

m
→‎{{header|Perl 6}}: fix silly error.
m (→‎{{header|Perl 6}}: fix silly error.)
Line 576:
 
=={{header|Perl 6}}==
{{incorrect|Perl 6|Pisano period (p, 1) for integers 1 to 180 is incorrect. Many odd values instead of none for p greater than 2.}}
{{works with|Rakudo|2020.02}}
Didn't bother making two differently named routines, just made a multi that will auto dispatch to the correct candidate.
Line 585 ⟶ 584:
my %cache;
 
multi pisano-period (Int $p where *.is-prime, Int $k where * > 0 = 1 ) {
return %cache{"$p|$k"} if %cache{"$p|$k"};
my $fibmod = @fib.map: * % $p**$k;
Line 591 ⟶ 590:
}
 
multi pisano-period (Int $p where * > 0, Int $k where * > 0 = 1 ) {
[lcm] prime-factors($p).squishBag.map: { samewith $_.key, $k.value }
}
 
Line 614 ⟶ 613:
 
Pisano period (p, 1) for integers 1 to 180
1 3 8 36 20 24 16 12 3 824 60 10 24 28 48 40
324 36 24 18 60 16 30 48 24 20100 84 872 48 14 120
30 348 40 36 80 24 76 18 56 60 40 48 88 30 40120
48 32 24 112 16 60300 72 84 108 2472 20 48 72 42 58 120
60 30 1648 396 140 120 136 36 48 240 70 24 148 228 40200
18 80 168 78 120 60 8216 120 168 48 180 264 56 3060 44 120
112 48 120 96 180 2448 196 336 48 40 120 60300 50 72 208 84 80
108 72 2472 108 60 152 48 76 72 240 42 56168 174 144 120
10 110 60 40 30 20500 48 256 3192 88 420 130 120 144 408 40360
36 276 48 46 240 32 210 140 24 140 444 16112 228 148 120600
50 1836 72 240 60 168 316 78 216 60240 48 24216 328 120 40
168 336 48 28364 180 72 264 348 168 80 400 30120 232 132 178 120</pre>
 
=={{header|Phix}}==
10,333

edits