Created
August 21, 2026 10:29
-
-
Save miura1729/bb57c69a6bbf71448887bab5f8e2bef8 to your computer and use it in GitHub Desktop.
div 7
This file contains hidden or 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
| #include <stdio.h> | |
| int div7(int n) | |
| { | |
| int res = 0; | |
| int cnt = 0; | |
| while (n > 0) { | |
| int nn = (8 - (n & 7)); | |
| res = res + (nn << cnt); | |
| n -= ((nn << 3) - nn); | |
| n >>= 3; | |
| cnt += 3; | |
| } | |
| return res; | |
| } | |
| main(){ | |
| for(int i = 0; i < 1000; i++) { | |
| printf("%d %d \n", i, div7(i)); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment