Very basic practice problem that is massively confusing me for some reason. I have the number 0x55555555 that I want to get in C using only the bit-wise operators | and <<. You can also use any number less then 0xFF as part of shift/or. Lastly less then 6 operators have to be used, so I can't just spam shifts one at a time and then | with 5.
The issue for me is that I am struggling to figure out how to get the 5/0101 to repeat. I can of course just shift 5 over, however that just leaves 0's behind such as this (5<<4 -> 0101 0000).
int test () {return (5<<21);}
uint32_t _55 = 0x55;
uint32_t _5555 = (_55 << 8) | _55;
uint32_t _55555555 = (_5555 << 16) | _5555;