public class CouponCollector { public static void main(String[] args) { int n = Integer.parseInt(args[0]); boolean[] trovato = new boolean[n]; int distinti = 0; int tentativi = 0; while (distinti < n) { int r = (int) (Math.random() * n); tentativi++; if (!trovato[r]) { trovato[r] = true; distinti++; } } System.out.println(tentativi + " tentativi"); } }