(With all the caveats of local and symboltable hacking, of course.)sub invert { my ($n, $p)=@_; # Trusting $p to be a prime... local *expp = sub { my ($n, $m)=@_; return 1 unless $m; ($m%2 ? $n : 1) * expp($n, $m >> 1)**2 % $p; }; expp($n, $p-2); }
-- Randal L. Schwartz, Perl hacker
Be sure to read my standard disclaimer if this is a reply.
In reply to Re: Isn't Perl5 ready for C<my sub>?
by merlyn
in thread Isn't Perl5 ready for C<my sub>?
by blazar
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |