Minecraft wiki entry for Enchanting_mechanics, associated text: Top slot enchantment level = floor(max(base / 3, 1))
Middle slot enchantment level = floor((base × 2) / 3 + 1)
Bottom slot enchantment level = floor(max(base, b × 2))