Limestone is a sedimentary rock that is composed primarily of calcium carbonate (CaCO3). It can be formed both chemically and organically. Chemically, limestone is formed when calcium carbonate precipitates out of water. This can happen when the water evaporates, or when the water becomes saturated with calcium carbonate. Organically, limestone is formed when marine organisms, such as corals and shellfish, secrete calcium carbonate. These organisms use calcium carbonate to build their shells and skeletons. When these organisms die, their shells and skeletons accumulate on the sea floor and eventually become buried and compressed into limestone.