my $tempA = Math::BigInt->new($a); $b = $tempA->bmodpow($M,$n); #set b = a^m