function monte_carlo_simulation(iterations)
inside_circle = 0
for _ in 1:iterations
if x^2 + y^2 <= 1
inside_circle += 1
end
end
return (inside_circle / iterations) * 4
end
# Configuración
iterations = 1_000_000
# Ejecución con temporizador
@
time pi_estimate
= monte_carlo_simulation
(iterations
)
# Resultados
println("Estimación de Pi: ", pi_estimate)
ZnVuY3Rpb24gbW9udGVfY2FybG9fc2ltdWxhdGlvbihpdGVyYXRpb25zKQogICAgaW5zaWRlX2NpcmNsZSA9IDAKICAgIGZvciBfIGluIDE6aXRlcmF0aW9ucwogICAgICAgIHgsIHkgPSByYW5kKCksIHJhbmQoKQogICAgICAgIGlmIHheMiArIHleMiA8PSAxCiAgICAgICAgICAgIGluc2lkZV9jaXJjbGUgKz0gMQogICAgICAgIGVuZAogICAgZW5kCiAgICByZXR1cm4gKGluc2lkZV9jaXJjbGUgLyBpdGVyYXRpb25zKSAqIDQKZW5kCgojIENvbmZpZ3VyYWNpw7NuCml0ZXJhdGlvbnMgPSAxXzAwMF8wMDAKCiMgRWplY3VjacOzbiBjb24gdGVtcG9yaXphZG9yCkB0aW1lIHBpX2VzdGltYXRlID0gbW9udGVfY2FybG9fc2ltdWxhdGlvbihpdGVyYXRpb25zKQoKIyBSZXN1bHRhZG9zCnByaW50bG4oIkVzdGltYWNpw7NuIGRlIFBpOiAiLCBwaV9lc3RpbWF0ZSkK