Charles Babbage's design for the first automatic mechanical calculator. The Difference Engine was a special purpose device intended for the production of mathematical tables. Babbage started work on the Difference Engine in 1823 with funding from the British Government. Only one-seventh of the complete engine, about 2000 parts, was built in 1832 by Babbage's engineer, Joseph Clement. This was demonstrated successfully by Babbage and still works perfectly. The engine was never completed and most of the 12,000 parts manufactured were later melted for scrap.
It was left to Georg and Edvard Schuetz to construct the first working devices to the same design which were successful in limited applications. The Difference Engine No. 2 was finally completed in 1991 at the Science Museum, London, UK and is on display there.
The engine used gears to compute cumulative sums in a series of registers: r[i] := r[i] + r[i+1]. However, the addition had the side effect of zeroing r[i+1]. Babbage overcame this by simultaneously copying r[i+1] to a temporary register during the addition and then copying it back to r[i+1] at the end of each cycle (each turn of a handle).