Thermoelectric figure of merit of degenerate and nondegenerate semiconductors