The ones with really long halflives formed way back during the supernova that created all of the atoms that make up our solar system.
The ones with shorter halflives form naturally when cosmic rays hit otherwise stable atoms, altering their nuclei to form radioactive isotopes. For example, when normal atmospheric nitrogen is hit with cosmic rays, it can form carbon-14, a radioactive isotope of carbon-12.
Some don’t form naturally at all. Many of the elements at the very bottom of the periodic table can only be reliably created artificially in particle accelerators.
Latest Answers