The adding machine is a mechanical device that adds numbers. The forerunners of such devices were prehistoric and may have been scratches in rock, notches in wood, knots in a strip of hide, or pebbles grouped together. The regularly spaced knots in a ship's line that were added to tell the depth of the water, or an array of stone counters shifted on a board in ancient and medieval times, were used to perform some of the functions of an adding machine, as were the beads-on-wires of the medieval Chinese suan pan (suan p'an), called abacus today. All these early devices required their operators to know how to count, and they demonstrated that physical objects could be placed and moved to represent numbers and sums. Knowledge of these devices was used to design the earliest-known machine that itself added numbers by moving and shifting physical objects without requiring a human operator to know how to add. The physical objects were gear wheels and worm gears, meshed to form a train of gears. Described in a treatise by Hero of Alexandria that dates from the 2d century ¥, this machine could add up the stades (kilometers or miles) that a carriage traveled.
The principle of its operation, based on the rotation of the pegged or single-tooth wheel, is still found today in water meters, gas meters, and bicycle and automobile odometers. In the 17th century the French mathematician Blaise Pascal converted the mechanical arrangement of the odometer into an adding machine that a clerk could operate. In the same century the German mathematician and philosopher Gottfried Wilhelm von Leibniz extended the adding ability of Pascal's machine to produce a multiplying calculator that achieved results by adding. The mechanical principles of the adding machine were extended and incorporated in hand-cranked calculators during the 18th and 19th centuries and in electrically operated calculators during the 20th century. By the middle of the 20th century, the electronic circuitry of the computer began to replace the electromechanical adding operations of business office machines.