Implement the following in Python:
-
Radioactive decay simulation:
Half-life is 1 day. Write a simulation function that takes:
-
input: integer
m
(number of days), integer
n
(number of atoms)
-
process: simulate independent decay over time (you may model survival each day with probability 0.5, or equivalently sample each atom’s decay time)
-
output: the final
state
of each particle (e.g., a boolean list/array of length n indicating survived/decayed after m days) and/or the number of survivors.
Also discuss runtime and how you would validate correctness against the analytic Binomial(n, 0.5^m) result.
-
Factorial and trailing zeros:
-
(a) Implement a factorial function in Python (mention multiple approaches).
-
(b) Given an integer
n
, compute the number of trailing zeros in
n!
efficiently (better than computing n! explicitly).