Nobody really knows how exercise helps prevent loss of mental function, but every factor that helps protect you from getting a heart attack or stroke also protects you from dementia. Anything that protects blood vessels also protects your brain. Heart attacks and dementia are associated with eating too much fat, saturated fat, fried foods, refined carbohydrates, too many calories, and not eating enough vegetables, nuts, beans and other seeds; being overweight, not exercising, taking more than two alcoholic drinks a day, and smoking. More on dementia
The Nurses' Health Study from the Harvard School of Public Health shows that exercising your muscles improved cognitive function in older women ( JAMA, September 2004). Another study shows that more than 85 percent of middle-aged people who start an exercise program drop out in the first six weeks. You're more likely to continue if you exercise with others: a spouse or friend, with a personal trainer, or in an organized group or class.