roommate went to an interview and got this one:

**Rules:**

permitted to use rand();

RAND\_MAX = 32 767;

no use of division or modulo;

**TODO:**
Write a function that takes one int parameter and returns
int in range 0 - parameter.

Head hurts, can't sleep. Any help appreciated.
Thanks