Donald Trump told thousands of boy scouts how to “achieve your dreams”: by highlighting career advice from a bankrupt property developer who did not do business with people of colour.

Speaking to a crowd of 40,000 at the National Boy Scout Jamboree, the President talked about William Levitt, who once had a “big yacht” and “an interesting life”.

He described meeting the late property developer at a party after a series of failed business ventures later in Levitt’s life.

“And in the end he failed and he failed badly. Lost all of his money. He went personally bankrupt. And he was now much older.

“And I saw him at a cocktail party and it was very sad because the hottest people in New York were at this party,” Mr Trump explained.

“And I see sitting in the corner, was a little old man who was all by himself. Nobody was talking to him. I immediately recognised that that man was the once great William Levitt of Levittown.”

Mr Trump asked him why his business had failed.

“And he said, ‘Donald, I lost my momentum. I lost my momentum.’ A word you never hear when you’re talking about success,” the President said

“He lost his momentum, meaning he took this period of time off long, years, and then when he got back, he didn’t have the same momentum.”

“In life, I always tell this to people. You have to know whether or not you continue to have the momentum. And if you don’t have it that’s OK.”

Donald Trump's international Presidential trips Show all 22 1 /22 Donald Trump's international Presidential trips Donald Trump's international Presidential trips French President Emmanuel Macron and US President Donald Trump AFP/Getty Images Donald Trump's international Presidential trips French President Emmanuel Macron and US President Donald Trump talk as they leave the Army Museum at Les Invalides in Paris AFP/Getty Images Donald Trump's international Presidential trips German Chancellor Angela Merkel and US President Donald Trump arrive for the group photo at the G7 Taormina summit on the island of Sicily in May 2017 Getty Images Donald Trump's international Presidential trips Mr Trump was pressed on the subject at the G7 summit in Italy Getty Donald Trump's international Presidential trips US President Donald Trump gives a speeech at the Warsaw Uprising Monument on Krasinski Square Getty Donald Trump's international Presidential trips US President Donald Trump and Britain's Prime Minister Theresa May during a ceremony at the NATO headquarters before the start of a summit in Brussels, Belgium Reuters Donald Trump's international Presidential trips Montenegro's Prime Minister Dusko Markovic is seen to the right of Donald Trump at a Nato summit in Brussels REUTERS Donald Trump's international Presidential trips Pope Francis meeting with US President Donald J. Trump EPA Donald Trump's international Presidential trips Pope Francis poses with US President Donald Trump and First Lady Melania Trump AFP/Getty Images Donald Trump's international Presidential trips US President Donald Trump arrives at Palazzo del Quirinale ahead of the meeting with Italian President Sergio Mattarella Ufficio Stampa Presidenza della via Getty Donald Trump's international Presidential trips US President Donald Trump is seen during a joint press conference with the Palestinian leader at the presidential palace in the West Bank city of Bethlehem AFP/Getty Images Donald Trump's international Presidential trips Palestinian president Mahmoud Abbas meets US President Donald Trump PPO via Getty Donald Trump's international Presidential trips Israeli Prime Minister Benjamin Netanyahu speaks with US President Donald Trump prior to the President's departure GPO via Getty Images Donald Trump's international Presidential trips US President Donald Trump and Israel's Prime Minister Benjamin Netanyahu shake hands after delivering a speech at the Israel Museum AFP/Getty Images Donald Trump's international Presidential trips US President Donald Trump and First Lady Melania Trump lay a wreath in the Hall of Remembrance as White House senior advisor Jared Kushner and Ivanka Trump watch on during a visit to the Yad Vashem Holocaust Memorial museum AFP/Getty Images Donald Trump's international Presidential trips US President Donald Trump visit to Yad Vashem Holocaust museum in Jerusalem accompanied by Prime Minister Benjamin Netanyahu GPO via Getty Images Donald Trump's international Presidential trips US President Donald Trump takes his seat before his speech to the Arab Islamic American Summit in Riyadh in Saudi Arabia Reuters Donald Trump's international Presidential trips Saudi Arabia's King Salman bin Abdulaziz al-Saud, US President Donald Trump and US First Lady Melania Trump look at a display of Saudi modern art at the Saudi Royal Court in Riyadh AFP/Getty Images Donald Trump's international Presidential trips US President Donald Trump and Saudi Arabia's King Salman bin Abdulaziz al-Saud take part in a signing ceremony at the Saudi Royal Court in Riyadh AFP/Getty Images Donald Trump's international Presidential trips King Salman presents Donald Trump with The Collar of Abdulaziz al-Saud Medal at the Royal Court Palace on 20 May AP Donald Trump's international Presidential trips US President Donald Trump is welcomed by Saudi King Salman bin Abdulaziz al-Saud upon arrival at King Khalid International Airport in Riyadh AFP/Getty Images Donald Trump's international Presidential trips U.S. President Donald Trump and first lady Melania Trump walk on the South Lawn prior to their first foreign trip Getty Images

People on social media pointed out Levitt was known for building "restricted communities" and had a policy of not renting or selling property to people of colour.

At the jamboree, the President only briefly read from the autocue, mentioning American values, roaring campfires and the importance of perseverance.

Most of the speech involved his usual subjects, however, including the “fake news”, his election wins in each state, and criticising former President Barack Obama for not attending a jamboree. His remark on Mr Obama received the loudest response of cheers and boos.

Mr Trump also told the boys, "Who the hell wants to talk about politics?"

"You know, I go to Washington and I see all these politicians and I see the swamp and it's not a good place,” said Mr Trump.

“In fact, today I said we ought to change it from the word 'swamp' to the word 'cesspool' or perhaps to the word 'sewer.' It's not good. I see what's going on and believe me, I'd much rather be with you, that I can tell you,” Mr Trump said.

He said he has 10 former Boy Scouts in his cabinet and White House, and invited Health Secretary Tom Price onto the stage.

He joked that he would fire Mr Price if he did not get enough votes in the Senate to push through the new health care bill.