Rational cooperation in the finitely repeated prisoners' dilemma