{}
run-icon
main.py
import math def birthday_paradox_probability(n, m): # n: number of files # m: number of possible hash values (2^64 for a 64-bit hash) probability = 1 - math.exp(-n * (n - 1) / (2 * m)) return probability # Number of files n = 1_000_000 # Number of possible hash values for a 64-bit hash m = 2**64 # Calculate the probability probability = birthday_paradox_probability(n, m) print(f"The probability that at least two of {n} files have the same 64-bit-hash, is: {probability:.12f}")
Output