fork(3) download
  1. import java.util.*;
  2. import java.lang.*;
  3.  
  4. class Main
  5. {
  6. public static void main (String[] args) throws java.lang.Exception
  7. {
  8. int partidas = 15000000;
  9. int total = 0;
  10. for (int i=0; i<partidas; i++)
  11. {
  12. int contador = 1;
  13. while (Math.random()<0.5)
  14. {
  15. contador++;
  16. }
  17. total += Math.pow(2, contador);
  18. }
  19. System.out.println();
  20. System.out.println("Partidas: "+partidas);
  21. System.out.println("Total premios: "+total);
  22. System.out.println("Media premios: "+((double)total/partidas));
  23. }
  24. }
Success #stdin #stdout 4.6s 245824KB
stdin
Standard input is empty
stdout
Partidas: 15000000
Total premios: 498357404
Media premios: 33.223826933333335