solution to problem 23

it requires a generator and uses System.Random