Limestone is a sedimentary rock composed primarily of calcite, a calcium carbonate mineral with a chemical composition of CaCO3. It usually forms in clear, calm, warm, shallow marine waters.
Limestone is usually a biological sedimentary rock, forming from the accumulation of shell, coral, algal, fecal, and other organic debris. It can also form by chemical sedimentary processes, such as the precipitation of calcium carbonate from lake or ocean water.
Most limestones form in calm, clear, warm, shallow marine waters. That type of environment is where organisms capable of forming calcium carbonate shells and skeletons can thrive and easily extract the needed ingredients from ocean water.
When these animals die, their shell and skeletal debris accumulate as a sediment that might be lithified into limestone. Their waste products also contribute to the sediment mass.