Trying to solve the math behind this hacker rank problem, but it's been a long time since grad school and I've forgotten a lot.
The question: There is an ideal random number generator, which given a positive integer M can generate any real number between 0 to M, and probability density function is uniform in [0, M].
Given two positive integers A and B and we generate x and y using a random number generator with uniform probability density function [0, A] and [0, B] respectively, what's the probability that x + y is less than C? where C is a positive integer. For simplicity sake, assume A <= B.
I ended with the following cases, but obviously my math is wrong. Case 1: A == B == C 0.5 Case 2: C > A & C > B 1 Case 3: C > A & C <= B) 0.5*1+0.5*C/B Case 4: C < A & C < B 0.5*C/A + 0.5*C/B What am I missing here?