Did you see what was posted under the entry for tomorrow (Thu Oct 03) on What's New? 

How are you.

-bash-4.2$ nano -w 1002a.phps
-bash-4.2$ date
Wed Oct  2 14:26:46 EDT 2019
-bash-4.2$

--

  Why do we on average lose a bet that at least 
  one six appears when we roll a die four times? 

import java.util.Arrays; 

public class Experiment {
  public static void main(String[] args) {
     int[] outcomes = new int[6];
     Dice a = new Dice(); 
     System.out.println( Arrays.toString( outcomes ) ); 
     for (int i = 0; i < 60000; i++) {
       int n = a.spit();  
       outcomes[n-1] = outcomes[n-1] + 1; 
     }
     System.out.println( Arrays.toString( outcomes ) ); 
  }
}

public class Dice {
  public int spit() {
    return (int)(Math.random() * 6) + 1; 
  }
}

--

import java.util.Arrays; 

public class Experiment {
  public static void main(String[] args) {
     Dice a = new Dice();
     boolean won = false; 
     for (int i = 0; i < 4; i++) {
       int n = a.spit(); 
       System.out.print( " " + n ); 
       if (n == 6) {
         won = true;   
       }
     }
     System.out.println( won ? " You won." : " You lost" ); 
  }
}

--

Welcome to DrJava.  Working directory is C:\Users\dgerman\Desktop
> run Experiment
 5 6 2 3 You won.
> run Experiment
 5 2 5 2 You lost
> run Experiment
 2 4 4 3 You lost
> run Experiment
 2 4 6 3 You won.
> run Experiment
 4 1 4 3 You lost
> run Experiment
 2 3 5 6 You won.
> run Experiment
 1 1 6 4 You won.


--

import java.util.Arrays; 

public class Experiment {
  public static void main(String[] args) {
     Dice a = new Dice();
     int wins = 0, losses = 0; 
     for (int times = 0; times < 10000; times++) { // game 
       boolean won = false; 
       for (int i = 0; i < 4; i++) {
         int n = a.spit(); 
         // System.out.print( " " + n ); 
         if (n == 6) {
           won = true;   
         }
       }
       // System.out.println( won ? " You won." : " You lost" ); 
       if (won) wins += 1; else losses += 1; 
     }      
     System.out.println( wins * 100.0 / (wins + losses) ); 
  }
}

--

Welcome to DrJava.  Working directory is C:\Users\dgerman\Desktop
> run Experiment
51.24
> run Experiment
52.13
> run Experiment
51.98
> run Experiment
51.97
> run Experiment
51.77
> run Experiment
51.96
> run Experiment
51.3
> run Experiment
52.01


--

http://horstmann.com/bigj6/bugs.html

--

https://cs.indiana.edu/classes/c212/fall2018/jk216-formula.jpg

--

https://math.stackexchange.com/questions/1000488/throw-a-dice-4-times-what-is-the-probability-6-be-up-at-least-one-time

--

https://www.cut-the-knot.org/Probability/ChevalierDeMere.shtml

--

import java.util.Arrays; 

public class Example {
  public static void main(String[] args) {
    int[][] m = new int[4][]; 
    System.out.println( Arrays.toString(m) ); 
    m[0] = new int[]{16,  3,  2, 13}; 
    m[1] = new int[]{ 5, 10, 11,  8}; 
    m[2] = new int[]{ 9,  6,  7, 12}; 
    m[3] = new int[]{ 4, 15, 14,  1}; 
    Example.show(m); 
  }
  public static void show(int[][] a) {
    for (int row = 0; row < a.length; row++) {
      for (int col = 0; col < a[row].length; col++) {
        System.out.print(a[row][col] + " ");  
      }
      System.out.println(); 
    }
  }
}

--

Welcome to DrJava.  Working directory is C:\Users\dgerman\Desktop
> run Example
[null, null, null, null]
16 3 2 13 
5 10 11 8 
9 6 7 12 
4 15 14 1 


--

import java.util.Arrays; 

public class Example {
  public static void main(String[] args) {
    int[][] m = new int[4][]; 
    System.out.println( Arrays.toString(m) ); 
    m[0] = new int[]{16,  3,  2, 13}; 
    m[1] = new int[]{ 5, 10, 11,  8}; 
    m[2] = new int[]{ 9,  6,  7, 12}; 
    m[3] = new int[]{ 4, 15, 14,  1}; 
    Example.show(m); 
    System.out.println( Example.check(m) ); // true if all numbers appear exactly 
    // once and false otherwise (numbers are 1, 2, 3, ..., size^2-1, size^2)
  }
  public static boolean check(int[][] a) {
    int size = a.length; 
    int[] numbers = new int[size*size]; 
    for (int i = 0; i < size; i++) { // rows
      for (int j = 0; j < size; j++) { // cols 
        int n = a[i][j]; 
        if (n <= 0 || n > size*size) return false; 
        if (numbers[n-1] == 0) {
          numbers[n-1] += 1; 
        } else return false; 
      }
    }
    return true; 
  }
  public static void show(int[][] a) {
    for (int row = 0; row < a.length; row++) {
      for (int col = 0; col < a[row].length; col++) {
        System.out.print(a[row][col] + " ");  
      }
      System.out.println(); 
    }
  }
}

--

Welcome to DrJava.  Working directory is C:\Users\dgerman\Desktop
> run Example
[null, null, null, null]
16 3 2 13 
5 10 11 8 
9 6 7 12 
4 15 14 1 
true