You are viewing a single comment's thread. Return to all comments →
from math import gcd
def proba(n, k): count=0 dice1=range(1, n+1) dice2=range(1, n+1) for i in dice1: for j in dice2: if i + j <= k: count+=1 nbr_event = n*n
pgcd=gcd(count, nbr_event) num=count//pgcd denum= nbr_event//pgcd return f"{num}/{denum}"
proba(6, 9)
Seems like cookies are disabled on this browser, please enable them to open this website
Day 2: Basic Probability Puzzles #1
You are viewing a single comment's thread. Return to all comments →
from math import gcd
def proba(n, k): count=0 dice1=range(1, n+1) dice2=range(1, n+1) for i in dice1: for j in dice2: if i + j <= k: count+=1 nbr_event = n*n
proba(6, 9)