employer cover photo
employer logo
employer logo

Trexquant Investment

Is this your company?

Trexquant Investment Interview Question

How to write a function that return 4 times the input, but can not use multiply and add operators?

Interview Answers

Anonymous

Nov 5, 2017

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.

Anonymous

Nov 6, 2017

Your first opinion is very close to the answer. Think about using only one line code to solve the question. Besides, think about the question changes to 4000 times the input and do not use for- loop.