Jump to content

Curzon numbers: Difference between revisions

m
→‎{{header|Perl}}: more efficient calculations
m (→‎{{header|Perl}}: more efficient calculations)
Line 1,091:
 
=={{header|Perl}}==
{{libheader|ntheory}}
<syntaxhighlight lang="perl">use strict;
use warnings;
use ntheory 'powmod';
 
sub modpow {
my($b,$e,$m) = @_;
my $p = 1;
while ($e) {
$p = $p * $b % $m if $e & 1;
$b = $b * $b % $m;
$e >>= 1
}
$p
}
 
sub curzon {
Line 1,110 ⟶ 1,101:
while (++$n) {
my $r = $base * $n;
push @C, $n if $r == modpow powmod($base, $n, $rbase * $n + 1) == $base * $n;
return @C if $cnt == @C;
}
2,392

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.