Last active
August 20, 2022 07:17
-
-
Save miura1729/2aa966367b6b9e82ae3d2bd5a278f034 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
main() { | |
printf("%d\n ", mod5(1)); | |
printf("%d\n ", mod5(2)); | |
printf("%d\n ", mod5(3)); | |
printf("%d\n ", mod5(4)); | |
printf("%d\n ", mod5(5)); | |
printf("%d\n ", mod5(11)); | |
printf("%d\n ", mod5(32)); | |
printf("%d\n ", mod5(10)); | |
printf("%d\n ", mod5(15)); | |
printf("%d\n ", mod5(30)); | |
printf("%d\n ", mod5(567824)); | |
printf("%d\n ", mod5(567825)); | |
} | |
int mod5(unsigned int n) | |
{ | |
unsigned int t; | |
t = (n & 0x0f0f0f0f) + ((n >> 4) & 0x0f0f0f0f); | |
t = t + (t >> 16); | |
t = t + (t >> 8); | |
t = t + (t >> 4); | |
return ((t ^ (t >> 2)) & 0x3); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment