Leading an active lifestyle in your 20s can lead to better memory and cognition later in life, researchers of a recent study say.

This Coronary Artery Risk Development in Young Adults Study followed 2,700 men and women for 25 years. Researchers found that teenagers and young adults who did better on treadmill tests tended to do better on memory and problem solving tests in middle age.

It's common knowledge that regular exercise is part of a healthy lifestyle and can prevent obesity and heart disease, and previous studies have shown exercise can create a sharper mind. However, this study is the first to look at how exercising at a younger age affects cognition in later years.

"Things that would be good for the heart are probably going to be good for the brain," David Jacobs, a professor at the University of Minnesota's School of Public Health involved in the study, said according to NPR.

After assessing each participant's memory, the findings revealed that on average, the least fit participants were able to remember seven out of 15 words in a memory test and the fittest were able to remember eight.

Participants also had their executive function and coordination skills tested using colored cards and a series of numbers. Those who were healthiest were on average four seconds quicker to read out the correct colors on the executive function test, and they were able to more accurately substitute symbols for numbers.

Jacobs argues that even a slightly sharper mind can make a difference in later-life cognitive function. But just because you don't commit to a rigorous exercise routine when you're young doesn't mean all is lost.

"If you have not done everything exactly right - and that's pretty much everybody - you can make changes later in life," he said.