Bitwise Operation, Add one to a number without using +
Anonymous
int add (int n) { return n & 1 ? add (n>>1)<<1 : n | 1; } First expression in the ternary operator is carrying the 1 if the last binary digit is one, the second is adding the 1 if the last binary digit is 0
Check out your Company Bowl for anonymous work chats.