A recipe for staying sharp in old age has been uncovered by scientists who studied more than 2,000 men and women through their seventies and eighties.

The four key factors involved in preventing mental decline were found to be exercise, education, social activity and not smoking.

Researchers carried out a series of memory and mental tests on 2,500 men and women aged 70 to 79 over a period of eight years.

Just over half the participants showed a normal rate of age-related decline while 16% suffered a major reduction in their mental faculties.

However, 30% of the study volunteers remained unchanged and in some cases even showed an improvement in performance over the years.

The researchers then examined what lifestyle factors stood out among those people who were able to remain quick-witted in old age.

Study leader Dr Alexandra Fiocco, from the University of California at San Francisco, said: "To this day, the majority of past research has focused on factors that put people at greater risk to lose their cognitive skills over time, but much less is known about what factors help people maintain their skills."

The research, published in the journal Neurology, revealed a unique profile that distinguished people who avoided mental decline with the passing years.

Those who exercised moderately or vigorously at least once a week were 30% more likely to "stay sharp" than people who did not.

Individuals with a good education were nearly three times more likely to maintain their mental faculties than those with less education. Likewise, high levels of literacy were associated with a five-fold better chance of side-stepping age-related mental decline.

Non-smokers were nearly twice as likely to remain mentally fit than smokers. And people who were socially active - either by working or volunteering, or by living with someone - were 24% more likely to avoid mental deterioration in later life.

"Some of these factors such as exercise and smoking are behaviours that people can change," said Dr Fiocco. "Discovering factors associated with cognitive maintenance may be very useful in prevention strategies that guard against or slow the onset of dementia. These results will also help us understand the mechanisms that are involved in successful ageing."