int inverse(int __) {
int _=__;
_*= -~-~- (__*_);
_*= -~-~- (__*_);
_*= -~-~- (__*_);
_*= -~-~- (__*_);
return _;
}Not quite obvious, but the code above will find the multiplicative inverse of its odd parameter, e.g. N*inverse(N) = 1 mod 2^32.
No comments:
Post a Comment