Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Introduction to JavaScript Programming with Nothing but a Browser Write a function simulateRadioactiveDecay that models the process of radioactive decay. The first parameter is the

image text in transcribed

Introduction to JavaScript Programming with Nothing but a Browser

Write a function simulateRadioactiveDecay that models the process of radioactive decay. The first parameter is the initial population of atoms, the second is the probability that any of those atoms will decay within a year. For example, calling simulateRadioactiveDecay (10000, 0.5) simulates what happens over time to a sample that contains 10,000 atoms of some radioactive material, where each atom has a 50 percent chance of decaying in a year. Your function should produce a trace on the console showing how many atoms remain at the end of each year until all of the atoms have decayed. For example, the output of your function might look like this: JavaScript Console > simulateRadioactiveDecay (10000, 0.5); There are 4916 atoms at the end of year 1. There are 2430 atoms at the end of year 2. There are 1228 atoms at the end of year 3. There are 637 atoms at the end of year 4. There are 335 atoms at the end of year 5. There are 163 atoms at the end of year 6. There are 93 atoms at the end of year 7. There are 46 atoms at the end of year 8. There are 18 atoms at the end of year 9. There are 8 atoms at the end of year 10. There are 2 atoms at the end of year 11. There is 1 atom at the end of year 12 There are o atoms at the end of year 13. As the numbers indicate, roughly half the atoms in the sample decay each year. In physics, the conventional way to express this observation is to say that the sample has a half-life of one year

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions

Question

Draft a proposal for a risk assessment exercise.

Answered: 1 week ago