In children and elderly an hour of exercise can improve memory and learning, say scientists.
The researchers found that walking or cycling regularly for between six months to a year can improve memory and problem solving skills in the elderly by between 15 and 20 per cent.
They have shown that such exercise can also increase the size of crucial parts of the brain.
The scientists have also discovered that children who are fit also tend to be better at multitasking and performing difficult mental tasks than unfit friends, the Telegraph reported.
Professor Art Kramer, director of the Beckman Institute for Advanced Science and Technology at the University of Illinois, who led the research, said their findings could have major implications for improving children's performance at school.
He said it could also be used to help the elderly combat memory loss in old age.
"It is a sad fact of ageing that our brain function decreases as we get older. Increasingly people are also living more sedentary lifestyles. While we know that exercise can have positive effects on cardiovascular disease and diabetes, we have found it can bring about improvements in cognition, brain function and brain structure," Kramer said.
"It is aerobic exercise that is important so by starting off doing just 15 minutes a day and working up to 45 minutes to an hour of continuous working we can see some real improvements in cognition after six months to a year.
"We have been able to do a lot of neuroimaging work alongside our studies in the elderly and show that brain networks and structures also change with exercise.
"Children also seem to benefit and we have found that aerobically fit children exhibit superior cognitive control to lower fit children," Kramer stated.
Work published earlier this year by his team showed that the hippocampus, the part of the brain involved in memory, of elderly people who exercised regularly for more than six months increased by two per cent, effectively reversing brain ageing by one to two years.
In the latest research, he also found that fitter children are better at crossing the street when distracted by music or holding a conversation on a hands-free mobile phone compared to those who were less fit.
He found that while the fit children could cross a road in a virtual reality simulation with ease when distracted, the less fit children tended walk at the same speed as the fitter children but misjudged the speed and distance of the computer generated vehicles.
"The low fitness kids were just as good at crossing the street when it was the only thing they were doing. If they were listening to music or talking on the headset, they performed badly. They often ended up with the screen going red to show they had been hit," Professor Kramer said.
"One way to look at it is that the high fit kids think more efficiently and so are better at multitasking," the researcher added.
The finding was presented at the American Association for the Advancement of Science annual meeting in Vancouver, and is due to be published later this year.