fork(1) download
  1. <?php
  2.  
  3. $dice = 8;
  4.  
  5. $storage = array_fill($dice,$dice*6-$dice+1,0);
  6.  
  7. for ($i=1;$i<1000000;$i++) {
  8. $sum=0;
  9. for ($j=1;$j<=$dice;$j++) {
  10. $num=mt_rand(1,6);
  11. $sum+=$num;
  12. }
  13. $storage[$sum]++;
  14. }
  15.  
  16. foreach ($storage as $index => $number) {
  17.  
  18. if ($index>=10) {
  19. echo $index;
  20. } else {
  21. echo "0",$index;
  22. }
  23.  
  24. for($i=0;$i<$number;$i+=1000) {
  25. echo "|";
  26. }
  27. echo"$number\n";
  28. }
  29.  
Success #stdin #stdout 4.25s 20568KB
stdin
Standard input is empty
stdout
080
09|5
10|24
11|70
12|187
13|447
14|979
15|||2050
16||||3688
17|||||||6239
18||||||||||9917
19||||||||||||||||15159
20|||||||||||||||||||||||22040
21|||||||||||||||||||||||||||||||30034
22||||||||||||||||||||||||||||||||||||||||39293
23|||||||||||||||||||||||||||||||||||||||||||||||||48907
24|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||58702
25|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||68093
26|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||74756
27||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||79339
28|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||80817
29||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||79736
30|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||74597
31||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||67656
32|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||58688
33||||||||||||||||||||||||||||||||||||||||||||||||||49073
34||||||||||||||||||||||||||||||||||||||||39093
35||||||||||||||||||||||||||||||29973
36||||||||||||||||||||||21784
37||||||||||||||||15203
38||||||||||9911
39|||||||6069
40||||3597
41|||2085
42||1049
43|455
44|190
45|71
46|18
47|5
480