Bloomberg Interview Question

Give a function, F1(), that returns either 1 or 0 randomly, write a function, F29() or F31(), that returns an event distribution of numbers from 0 to 32.

Interview Answers

Anonymous

Aug 19, 2015

integer 0-31 consists of 5 bits. call F1() 5 times, and built an integer from 5 bits.

1

Anonymous

May 10, 2015

The solution offered, which i did not get, was to use bit-shifting, and not something I have ever done, or have awareness of.