int n = 20; int m = 5; Random rd = new Random(); for (int i = 0; i < n; i++) { if (rd.Next() % (n - i) < m) { Response.Write(i.ToString()); m--; } }