Implement decay simulation and trailing-zero counting

Quick Overview

This Coding & Algorithms question for a Data Scientist role evaluates stochastic simulation and probability modeling for radioactive decay alongside combinatorics and number-theoretic reasoning for factorial trailing-zero computation, requiring implementation-level algorithmic thinking in Python.

Implement decay simulation and trailing-zero counting

Company: Upstart

Role: Data Scientist

Category: Coding & Algorithms

Difficulty: medium

Interview Round: Onsite

Implement the following in Python: 1) **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. 2) **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).

Quick Answer: This Coding & Algorithms question for a Data Scientist role evaluates stochastic simulation and probability modeling for radioactive decay alongside combinatorics and number-theoretic reasoning for factorial trailing-zero computation, requiring implementation-level algorithmic thinking in Python.

|Home/Coding & Algorithms/Upstart
Upstart logo
Upstart
Nov 29, 2025, 12:00 AM
mediumData ScientistOnsiteCoding & Algorithms
7
0

Implement the following in Python:

  1. 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.
  2. 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).

Submit Your Answer to Earn 20XP

Sign in to leave a comment

Loading comments...