WASHINGTON — President Donald Trump on Monday used an anecdote about Long Island master builder William Levitt to highlight to tens of thousands of Boy Scouts gathered in West Virginia, the merits of resilience and keeping momentum.

His remarks about Levitt — who ushered in an era of middle-class suburban living in the 1940s with the Levittown community in Nassau County — were part of an address that otherwise had the trappings of his classic stump speeches.

Trump spoke to the 30,000 Boy Scouts assembled for their annual jamboree in the town of Beaver about the failings of Obamacare, running against Hillary Clinton and the “fake news” media.

He appeared buoyed by the youthful energy of the crowd and offered the story of Levitt’s rise and fall as a parable.

“Never quit, never give up, do something you love,” Trump told the scouts.

Trump spoke admiringly about Levitt’s meticulous nature as a developer, how he’d inspect and clean homes late into the night in order to leave them “spotless” in the morning.

advertisement | advertise on newsday

Levitt ultimately sold his company for a “tremendous amount of money” and bought a “huge yacht,” Trump said. The developer missed working but could not return to his level of success, said Trump, who has transferred management of his own real estate empire to his two eldest sons as he serves in the White House.

Trump recalled seeing Levitt at a cocktail party hosted by fellow developer and Time Warner founder Steve Ross and asking Levitt, “What exactly happened? . . . You were one of the greats ever in this industry.”

Levitt responded, “Donald, I lost my momentum,” according to the president’s recollection.

The anecdote was lengthy and rambling but the president arrived at a conclusion that the Scouts in crowds should persist.

“Work hard and never, ever give up, and you’re going to be tremendously successful,” he told them.

Levitt, of Levitt & Sons, in the 1940s developed mass-produced, affordable houses for returning World War II veterans. Levittown is considered the country’s first modern suburban community.