Skip to content

eeeeeeeeeeekk/e-for-dinosaurs

Repository files navigation

E for Dinosaurs 🐱‍🐉

png

Calculating e (Euler's number) via Monte Carlo method in ancient programing languages (before 1991). To contribute to this project, see CONTRIBUTING.md before filing a PR

Implement the following pseudocode (Python3) or something like it to get Euler's number

import random

print("Number of iterations: ", end="")
n = int(input())

sum_total = 0
for _ in range(n):
    temp = 0
    counter = 0
    while temp < 1:
        temp += random.random()
        counter += 1

	sum_total += counter

print(sum_total/n)

Euler's Number is approximately 2.7182818284590452353602874713527

Thanks

Inspired by github.com/eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee/eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee

Licence

License: MIT