int x = n / 3; // <-- make this faster // for instance int a = n * 3; // <-- normal integer multiplication int b = (n << 1) + n; // <-- potentiall
Easy computation ... at most n iterations where n is your number of bits:
uint8_t divideby3(uint8_t x) { uint8_t answer =0; do { x>>=1; answer+=x; x=-x; }while(x); return answer; }