Gerstenhaber attended the now-defunct Speyer School, a school for rapid learners in New York City. Many years later, his daughter-in-law co-founded Speyer Legacy School, naming the new school after the original. After graduating from Speyer School, Gerstenhaber entered the Bronx High School of Science in 1940. From 1945 to 1947 he served in the infantry in the United States Army as a corporal assigned to the Office of Military Government for Germany.