What is the chance of having a villager selling two mending books in minecraft?

I was playing on my minecraft world trying to put a mending villager in my trading hall. It was pretty normal to have a mending villager in a trading hall so i put one in mine. After much anger I got one. Keep in mind that this villager had mending in its first slot at level 1. I had thought that the villager would give me another book if I had made him level 2. I figured why not use him to the fullest? Instead I got another mending book. Is this normal? or is it a freak of nature? Please help.

• To me this sounds like a freak of nature - that change has to be less than at least like 5% Commented Dec 27, 2020 at 20:37

In Bedrock edition, a librarian villager has a 50% chance of having any enchanted book trade in his first slot, and the same goes for the second slot. Assuming the probability of each slot is independent, that means that only 1 in 4 librarians will have two enchanted books in the first two slots.

Now, what are the chances of getting a Mending book?

There are 39 different enchantments, but we have to exclude Cleaving (only available in Java edition combat tests), Sweeping edge (only available in Java edition), and Soul speed (which can be obtained by piglin bartering, or in loot chests, but not by trading with villagers). So that leaves 36.

According to the official Wiki:

The enchantment is chosen randomly with equal chance of any enchantment type occurring (except for Soul Speed) and equal chance to get any level of the enchantment, meaning high-level enchantments are as likely as low-level enchantments.

So, it's a 1/2 chance to get a book instead of a bookshelf, and 1/36 for it to be Mending. Combining them together, you get a 1/2 * 1/36 = 1/72 chance to have Mending in the first slot. And if you got it, then for the second slot it's again a 1/72 chance of getting another Mending book.

That's a 1/72 * 1/72 probability, which equals 1/5184.

TL;DR: the chances of it happening are 1 in 5184, or 0.019%.