The Gay Science
Nietzsche may have encountered the idea of the Eternal Recurrence in the works of Heinrich Heine, who speculated that one day a person would be born with the same thought-processes as himself, and that the same applied to every other individual. Nietzsche expanded on this thought to form his theory, which he put forth in "The Gay Science" and developed in "Thus Spoke Zarathustra". Schopenhauer directly influenced this theory. Schopenhauer postulated that a person who unconditionally affirms life would do so even if everything that has happened were to happen again repeatedly.