Genes that influence people's health also shape how effectively they think, a study shows.
Scientists found that genes associated with diseases including Alzheimer's disease, schizophrenia, and autism also have an impact on some cognitive functions.
They say the study will help understanding of some of the links between low levels of cognitive function and poor health.
An international team, led by the University of Edinburgh, analysed data from around 100,000 people held in the UK Biobank.
This national resource of health data can help researchers discover why some people develop particular diseases and others do not.
When researchers compared each person's mental test data with their genome, they found that some traits linked to disease and thinking skills shared the same genetic influences.
To test the findings, researchers gathered data from previous genetic studies of other mental and physical health factors -- such as Alzheimer's disease, schizophrenia and autism.
Professor Ian Deary, Director of the Centre for Cognitive Ageing and Cognitive Epidemiology (CCACE) at the University of Edinburgh, who led the research, said: "In addition to there being shared genetic influences between cognitive skills and some physical and mental health states, the study also found that cognitive skills share genetic influences with brain size, body shape and educational attainments."
Researcher Saskia Hagenaars said: "The study supports an existing theory which says that those with better overall health are likely to have higher levels of intelligence."
Her colleague Dr Sarah Harris said: "The research highlights the importance of investigating biological pathways that influence both cognitive function and health related traits."
The study, published in Molecular Psychiatry, involved researchers in the UK, Germany and the US.
The analysis was carried out at the University of Edinburgh's Centre for Cognitive Ageing and Epidemiology (CCACE). It was supported by the Medical Research Council (MRC) and the Biotechnology and Biological Research Council (BBSRC) as part of the Lifelong Health and Wellbeing programme, a collaboration between the UK's Research Councils.