Both Matthew and Luke, in different places in their gospels, record the ancestry of Jesus. Matt. 1: 1–17 arranges the names into three groups divided by important historical events, from Abraham to David; Solomon to the Exile; and from the Exile to Jesus: two groups of fourteen generations (Matt. 1: 17), by omitting four Davidic kings, and a third group of only thirteen generations, culminating in the birth of the Messiah. The reduction to thirteen spoils the symmetry and is to be explained either because Matthew thus indicates that by the providence of God the neat scheme is overruled and the nation's destiny is fulfilled, or, more probably, because there is here a typical Matthaean muddle, as at 20: 22 when Jesus addresses James and John, just after Matthew has deliberately introduced their mother as their spokesperson.
‘Fourteen’ is in Hebrew by the method of gematria the numerical value of David: D + W + D = 4 + 6 + 4.
Matthew's genealogy includes four women, Tamar, Rahab, Ruth, and Bathsheba, who played important roles in OT history but at the end it is Joseph, the legal father of Jesus, who is named. The purpose of Matthew here is to show that Jesus is the legitimate heir to the throne of David, who is mentioned five times in 1: 1–17. Two of the four women had disreputable stories; and Ruth becomes great-grandmother of David though she was a foreigner; Bathsheba is deliberately recalled as ‘the wife of Uriah’ the Hittite. Thus Jesus' remote lineage comprised non-Jews: Matthew's first chapter anticipates the universalism of his last (28: 13). The genealogy does not explicitly assert that Joseph did not beget Jesus, as does Luke (3: 23), but Joseph, as a descendent of David, is necessarily accorded a role to authenticate Jesus' Messianic claim.
Luke's genealogy comes after the baptism narrative and before the public ministry of Jesus (Luke 3: 23–38) and traces the ancestry right back to Adam ‘son of God’; but unlike Matthew the line is taken through Nathan (2 Sam. 5: 14) instead of his brother Solomon, and no women are included. It would seem that by going back to the origins of humanity Luke is suggesting that Jesus is the Saviour of the whole world and not only of the people of Israel, as will be repeatedly explained elsewhere in Luke–Acts.
Luke's genealogy is artificially constructed, like Matthew's, but in a different way. He has compiled eleven groups of seven names, and just as the eleven disciples needed to be completed by one more (Acts 1: 26), so the eleven groups in the genealogy imply that there is one era yet to come—the time during which the gospel is to be preached to all nations (Luke 24: 47): eleven is manifestly incomplete.