How to write a function that return 4 times the input, but can not use multiply and add operators?
Anonymous
I dunno if this would be allowed, but you could just subtract the input value from zero 4 times and then return the negative of the result :p Also, this multiplication is trivial in binary representation. Think of it like multiplication by 100 in decimal. So you can use a left bit-shift operator (<<) to shift the binary digits over by two places. This assumes an integer input though.
Check out your Company Bowl for anonymous work chats.