Image copyright Thinkstock

A question one Radio 4 listener asked about the bloodline between Jesus and King David raised a wider genealogical issue. How many generations does it take before someone alive today is a descendant of everyone on the planet?

Listeners to the More or Less programme on Radio 4 have been challenging me to answer any fiendish question they can throw at me.

A question about Jesus's genealogy was rather interesting and the answer has astounding ramifications.

The Bible says Jesus was a descendant of King David. But with 1,000 years between them, and since King David's son Solomon was said to have had about 1,000 wives and mistresses, couldn't many of Jesus's peers in Holy Land have claimed the same royal ancestor?

Theory tells us that not only would all of Jesus's contemporaries be descended from King David, but that this would probably be the case even if Solomon had been into monogamy.

We can make this sort of prediction because over the past 15 years or so, these ideas have been studied as part of the research into understanding patterns in our own genome.

Who is Yan Wong? Yan Wong is an evolutionary biologist specialising in computer and mathematical modelling of evolutionary genetics. He is a presenter of the BBC One science programme Bang Goes The Theory and a contributor to More or Less. Bang Goes the Theory

The most successful approach has been to go backwards in time, taking a sample of people and imagining the patterns of inheritance in their ancestral family tree.

When applied to the question of who is descended from whom, the results can surprise even the professionals.

That's because geneticists normally study biological information - DNA - that people inherit from just one of their parents.

Just like a surname, or the male lines of descent quoted in the Bible, these generate lineages that shrink or expand rather slowly. That's why we expect the proportion of Smiths in the phone-book to fluctuate only a little from decade to decade.

The surprise comes if we look at inheritance from both parents. Here, the numbers change drastically as the generations go by. For instance, we have two parents, four grandparents, eight great-grandparents, and so on.

Each generation back, we multiply the number by two. This leads to what is called an exponential increase: 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024 and so on.

It's not long before we hit huge numbers. Take the specific case of Jesus and King David.

The number of generations between them is at least 35. Luke lists 42 generations down the male line, and Matthew gives an incomplete list of 27.

Image copyright Thinkstock Image caption Jesus Christ would have had more than 34 billion potential ancestors

These numbers agree reasonably well with an average time between generations of 25 or 30 years - an estimate taken from documented historical records from Iceland and Canada.

So back in the time of David, Jesus would have had at least 2 x 2 x 2 x 2 (35 times); in other words 2^35 - or more than 34 billion potential ancestors. That's far more than the total population of the world, of course.

This is a good illustration of what's been called the "genealogical paradox".

What about isolated communities? Image copyright funai "The one thing that stands a chance of scuppering our calculations is if the population is split into isolated groups," says Yan Wong. "However, to be considered separate, these groups need to basically never interbreed with each other. "To quote one of the papers on this subject, 'substantial forms of population subdivision can still be compatible with very recent common ancestors'. (Rohde et al., 2004). "In fact, even using current DNA studies, you can almost always detect distant shared relatives between distinct human populations (Henn et al., 2012)."

In short, we seem to have too many ancestors. The solution is that we have to take inbreeding into account. Many of these ancestors are duplicates; the same person can found through multiple routes in the family tree.

You are unlikely to be the product of inbreeding between recent ancestors. So initially, your increase in ancestors will indeed be almost exponential.

But as your family tree increases to thousands upon thousands, you will inevitably find many obscure branches that have interbred. That's when the numbers start tailing off.

Even so, by that time, you will have collected a large number of people in your ancestry. So it's not surprising that any two people in any one country probably won't need to go back many generations before finding a common ancestor.

More specifically, imagine the simplest case of a population of a constant size - say a million (the approximate size of the Holy Land at the time of Jesus).

If people in this population meet and breed at random, it turns out that you only need to go back an average of 20 generations before you find an individual who is a common ancestor of everyone in the population.

If you go back on average 1.77 times further again (35 generations) everyone in the population will have exactly the same set of common ancestors (although they will be related, of course, through different routes in all the different family trees).

Image copyright SPL Image caption Advances in DNA allow us to detect shared genetic ancestry

In fact about 80% of the people at that time in the past will be the ancestors of everyone in the present. The remaining 20% are those who have had no children, or whose children have had no children, and so on - in other words, people who were genetic dead-ends.

Apply that to the case of King David. According to this model, he would be a common ancestor of the whole population of the Holy Land somewhere between 20 and 35 generations after his life. That's even without Solomon sowing his seed so widely.

That's why everyone alive in the Holy Land at the time of Jesus would have been able to claim David for an ancestor.

Reductions in population caused by events such as the Assyrian invasions will have produced more inbred family trees, and shortened the number of generations needed to reach a common ancestry.

More or Less: Behind the stats Listen to More or Less on BBC Radio 4 and the World Service, or download the free podcast Download the More or Less podcast More stories from More or Less

What about the wider ramifications? A single immigrant who breeds into a population has roughly 80% chance of becoming a common ancestor. A single interbreeding event in the distant past will probably, therefore, graft the immigrant's family tree onto that of the native population. That makes it very likely that King David is the direct ancestor of the populations of many other countries too.

How far do we have to go back to find the most recent common ancestor of all humans alive today? Again, estimates are remarkably short. Even taking account of distant isolation and local inbreeding, the quoted figures are 100 or so generations in the past: a mere 3,000 years ago.

And one can, of course, project this model into the future, too. The maths tells us that in 3,000 years someone alive today will be the common ancestor of all humanity.

A few thousand years after that, 80% of us (those who leave children who in turn leave children, and so on) will be ancestors of all humanity. What an inheritance!