# Author: fi-le - https://fi-le.net # Licenced under MIT - https://mit-license.org/ import random tries = 1000000 # This quantifies the participant's patience average = 0 # This average is the one we used in the above demonstration average_n = 0 # This is the one we noted in the proof results = [] for i in range(tries): sum = 0 n = 0 while sum < 1: n += 1 sum += random.random() average += sum average_n += n # print(2 * sum) # Here we can print out each individual recorded sum. average /= tries / 2 average_n /= tries print(f"E is apparently {average}.") print(f"E is also apparently {average_n}.") print("Best estimate yet: 2.718228857942657")