Exercism c++ problem

even that approach is odd, using math instead of logic.

i use that approach with awk which doesn't have bit operations

i think there's a more direct way using masking