In numbers: Scottish population trends revealed in new report
Latest figures reveal the country's reliance on migration as country gets older.
With Brexit looming and Scotland facing an ageing population, extra strain could be put on social services.
Figures from the latest report from National Records of Scotland reveal the country's reliance on migration both from the rest of the UK and farther afield.
Here is a look at some of the changing factors in population.
Although there was a population increase in the past year, this came through migration alone.
A total of 22,900 people came into Scotland in 2016 from overseas and an additional 8800 from the rest of the UK.
The majority of these people were younger, with 52% being aged between 18-32.
In the 2011 census, the biggest net migration came from Poland, with 15% of migrants.
Just 10% of migrants came from the UK, the majority being from England with 9% of the share.
India and Ireland were in joint third place with 6% each.
In Scotland there were 5.31 million residents in 2016.
Some 17% (918,000) of people were aged under 16, 65% (3,510,000) of people were aged 16 to 64 and 18% (972,000) of people were aged 65 and over.
There is a projected increase to 28% in the number of pensioners in Scotland by 2040, with just a 1% increase in those of working age.
By 2040, the population of Scotland is expected to hit 5.78 million, by which time the number of people over the age of 65 would have almost doubled to 1,618,400.
The registrar general of Scotland, Tim Ellis, has warned this may have significant impacts on Scottish funding allocations, tax revenues, pensions, education, health and social care provision.
Women are having children at older ages.
In 2016, the average age for women giving birth was 31. In 2006, the average age was 29 and in 1996 it was 27.
The number of women having children at 40 has also increased.
In 1974, it was just 12 per 1000 births. By 2016 this had more than doubled to 25.
While not having a direct impact on population, there has been a significant change in how parents are choosing baby names.
The most popular baby names have tended to stay the same for several years - David was the favourite boys name for 18 years in a row, starting in 1974.
In 1975, 7.9% of parents chose the most popular name (David and Nicola) for their babies.
But there is now more variety.
By 2016, only 3.4% of parents went with the top baby names (Olivia and Jack).
A total of 2671 (10.9%) unique girls' names and 2072 (7.8%) unique boys' names were registered in 2016, showing a trend of shunning the common, traditional names.
This is an increase of 2.2% for boys and 3.8% of girls who had unique names in 1974.
Naming babies after fictional characters has also been a popular trend.
In 2015, the rebooted Star Wars was released. The following year the name Rey made it on to the chart for the first time.
Deaths were down 1.5% from 2015 but cancer remained the biggest cause at 6%.
Dementia deaths have doubled since 2000, a reflection of the ageing population.
There has been an increase in the number of deaths from alcohol or suicide.
There were 1265 deaths relating to alcohol in 2016 - an increase of 10%.
And there was an 8% increase in the number of deaths recorded as probable suicide - 56 more for a total of 728 deaths.