Skip to content

Instantly share code, notes, and snippets.

@originalsouth
Created January 27, 2025 17:53
Show Gist options
  • Save originalsouth/bf54f5f91fed928abaf9df7bf2b33fb6 to your computer and use it in GitHub Desktop.
Save originalsouth/bf54f5f91fed928abaf9df7bf2b33fb6 to your computer and use it in GitHub Desktop.
Calculate e by drawing random numbers
#!/usr/bin/env julia
using Random
function play()
r=0.0
counter=0.0
while r<1.0
r+=rand(Float64)
counter+=1.0
end
return counter
end
function drive(N::Int64)
e=0.0
for _ in 1:N
e+=play()
end
println(e/N)
end
@time drive(length(ARGS)==1 ? parse(Int64,ARGS[1]) : 1000)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment