The text is this:
1 The [fn]record of the genealogy of [fn]Jesus [fn]the Messiah, the son of David, the son of Abraham: 2 Abraham [fn]was the father of Isaac, [fn]Isaac the father of Jacob, and Jacob the father of [fn]Judah and his brothers. 3 Judah was the father of Perez and Zerah by Tamar, Perez was the father of Hezron, and Hezron the father of [fn]Ram. 4 Ram was the father of Amminadab, Amminadab the father of Nahshon, and Nahshon the father of Salmon. 5 Salmon was the father of Boaz by Rahab, Boaz was the father of Obed by Ruth, and Obed the father of Jesse. 6 Jesse was the father of David the king.
17 So all the generations from Abraham to David are fourteen generations; from David to the deportation to Babylon, fourteen generations; and from the deportation to Babylon to [fn]the Messiah, fourteen generations.
I was reading through it and thought, wasn't there something in the promise to Abram that this speaks to? Genesis ch12 is considered one of the great "bookends" but the promise isn't there. I found it a little later, in Genesis ch15.
13 God said to Abram, “Know for certain that your [fn]descendants will be strangers in a land that is not theirs, [fn]where they will be enslaved and oppressed four hundred years. 14 But I will also judge the nation whom they will serve, and afterward they will come out with [fn]many possessions. 15 As for you, you shall go to your fathers in peace; you will be buried at a good old age. 16 Then in the fourth generation they will return here, for the iniquity of the Amorite is not yet complete.”
Salmon was the husband of Rahab, therefore the generation where the Children of Abraham came out of Egypt was Salmon. It could be argued that the generation where the children of Abraham went into Egypt was Joseph, the brother of Judah.
For these to line up, for it to be 400 years, the inter-generational time between Jacob's son and Boaz's father, these 7 generations, must be able to be 400 years. Intergenerational time is the time from the birth of a child, and the birth of their child. If you look at the (sad) story of Judah and Tamar this is not a list of first-born offsprings. Perez was not Judah's first son, or even his second.
The patrilineal inter-generational length should be 400/(7-1) or 66 years. If you look at Noah or Abraham, their children were born when they were 70 and 100. If you look at modern life, the first offspring can be (tragically) in the young teens, but tend to (much more healthily) be in the mid-20's.
While it isn't impossible, it is very unlikely to have children in your mid-60's. This is post-menopausal age for women, typical menopause starting between age 48 and age 52, so there is argument that many of these are children of not-the-first-wife. This could be a series of "hidden Sarah's" where the miracle is child of old age for a series of women.