I think your think of "The Ultimate Computer" is a season two episode of Star Trek: The Original Series, first broadcast on March 8, 1968.
The M5 acknowledges Kirk, who asks M5 what its purpose is. M5 responds "To save men from the dangerous activities of space exploration." Kirk rejoins that it just acted contrary to its purpose by killing people. M5 recognizes the penalty for murder is death, so it shuts itself down, Spock responds that machines are more efficient than human beings: not better. He then dryly remarks that if McCoy's engrams were impressed in a computer, the resulting torrential flood of illogic would be most entertaining.