On a problem connected with Beta and Gamma distributions