Limestone is a type of sedimentary rock that is primarily composed of calcium carbonate (CaCO₃), generally in the form of calcite. It forms in marine environments as accumulating shells, coral, algae, and fecal matter, or when calcium carbonate precipitates directly out of lake or sea water.