I Have No Mouth and I Must Scream1974
by Harlan Ellison
This is a story set in a post-apocalyptic future. The Cold War progressed until it was too complicated for humans to manage, so the three major superpowers each developed a computer program to help run the war. When one of the programs becomes sentient it eliminates all of the human race except five persons, which it tortures for eternity.
— from OpenLibrary
4 editions at OpenLibrary