US subs used a computer called the TDC (Torpedo Data Computer) in WW2

an early electromechanical analog computer used for torpedo fire-control. Britain, Germany, and Japan also developed automated torpedo fire control equipment, but none were as advanced as the US Navy's TDC, as it was able to automatically track the target rather than simply offering an instantaneous firing solution. This unique capability of the TDC set the standard for submarine torpedo fire control during World War II. I also read there was one used by artillery units to put the round dead on target