Mr. Obama started out by trading quips with Mr. Letterman about his daughters’ future dating prospects (the boyfriends may get stressed out by the men with guns who hang around) and what happens to the parents of schoolchildren who have Malia and Sasha over for sleepovers (they get frisked).

But the conversation quickly turned serious, with a discussion of how the president would reach a decision about sending more troops to Afghanistan (by “asking some very hard questions”) and whether he thought racism was behind protests against his health care proposals (he said he did not).

The broader reason for Mr. Obama’s trip to Manhattan is the annual multiday gridlockfest that is the opening days of the United Nations General Assembly. Mr. Obama is scheduled to talk about global hot topics like climate change, development, poverty, the economy, the wars in Afghanistan and Iraq, and the efforts to rein in Iran’s nuclear ambitions.

But his first stop was at the Ed Sullivan Theater on Broadway to tape his first appearance on the Letterman show since being elected. (Mr. Obama appeared on the show as a candidate, and was on Jay Leno’s old show in the spring).

A woman from Missouri brought a heart-shaped potato to the show’s taping, and Mr. Letterman did a Top 10 list of reasons Mr. Obama agreed to do the show (No. 6: “Someone offers you 600 bucks, you take it, ladies and gentlemen”). Mr. Obama’s own explanation: “The main reason I’m here? I want to see that heart-shaped potato.”