ok, at first i solved the probabilities:



each arrow from ran5() is 1/5, each from rand2() is 0.5

rand5() is known
rand2() is (rand()%2)+6

so the function is (not elegant, but correct, i assume):

rand7(){
switch ((rand()%7)){ //first level: determin rand5() or rand2()
case 0: case 1: rand2(); break; // 2/7 prob
case 2: case3: case 4: case 5: case 6: rand5(); break; // 5/7 prob
}}