Pisano period: Difference between revisions
m
→{{header|Perl 6}}: fix silly error.
Thundergnat (talk | contribs) m (→{{header|Perl 6}}: fix silly error.) |
|||
Line 576:
=={{header|Perl 6}}==
{{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
[lcm] prime-factors($p).
}
Line 614 ⟶ 613:
Pisano period (p, 1) for integers 1 to 180
1 3 8
30
48 32 24 112
60 30
18 80 168 78 120
112 48 120 96 180
108 72
36 276 48 46 240 32 210 140 24 140 444
50
168 336 48
=={{header|Phix}}==
|