OK, the question is a bit poorly worded, but what I want to do is to select N numbers between 0 and MAX using rand\_int and choose the largest value.

This is how I'm attempting this, but for some reason it doesn't work:

```
rand_val(Count, Rng, Res) :-
    Count > 0,
    Count is Count - 1,
    rand_int(Rng, X),
    Res is max(X, Res),
    rand_val(Count, Rng, Res).

?- rand_val(2,100,Res).
-> no.

```

I'm a total newbie with Prolog (been studying it for just a few hours) so I'm probably just misunderstanding something.