Gerstenhaber finished his B.S. in mathematics at Yale University (1948). At Yale, he participated in the William Lowell Putnam Mathematical Competition and was on the team representing Yale University (along with Murray Gell-Mann and Henry O. Pollak) that won the second prize in 1947; each of them received a monetary prize of $30 ($410 in current dollar terms). His 1948 participation in the competition earned him a Top 10 ranking.