Created
September 6, 2015 06:57
-
-
Save sanjoy/cedce4ee4e0f71f982a1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
template<typename T> | |
bool is_even_0(T v) { | |
// v is odd iff it has an multiplicative inverse modulo 2^bitwidth(T) | |
for (T i = 1; i != 0; i++) | |
if (T(v * i) == T(1)) | |
return false; // odd | |
return true; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment