Advertisement
Guest User

Untitled

a guest
Jan 1st, 2018
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Julia 0.34 KB | None | 0 0
  1. # N times iteration. Initialize answer as 0.
  2. N = 1000000; ans1 = 0
  3.  
  4. # Roll two dice, x and y.
  5. for i in 1:N
  6.     # Define pip of die x.
  7.     x = rand(1:6)
  8.    
  9.     # Define pip of die y.
  10.     y = rand(1:6)
  11.     # Obtain the minimum pip.
  12.     z = min(x,y)
  13.    
  14.     # Add the minimum pip to answer.
  15.     ans1 = ans1 + z
  16. end
  17. print(ans1/N)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement