People who ran for longer on the treadmill performed better at tests of memory and thinking skills 25 years on, even after adjusting for factors such as smoking, diabetes and high cholesterol.

TOTAL FITNESS

People who had smaller time differences in their treadmill test 20 years later were more likely to perform better on the executive function test than those who had bigger differences.

"Many studies show the benefits to the brain of good heart health," said study author Dr David Jacobs.

"This is one more important study that should remind young adults of the brain health benefits of cardio fitness activities such as running, swimming, biking or cardio fitness classes."

Dr Jacobs said a concept was emerging of total fitness, incorporating social, physical and mental aspects of health.

"It's really a total package of how your body is and the linkage of that entire package of performance - that's related to cognitive function many years later and in mid-life," he told BBC News.

A spokeswoman for the Alzheimer's Society said: "A growing body of evidence suggests exercise may reduce the risk of cognitive decline and dementia, and much research has shown a link between healthy habits in mid-life and better health in old age.

"Investment in research is vital to better understand how we can protect our brains as we age."