Farting-I mean, flatulence-is due to poor absorption of carbohydrates.
Beans contain raffinose and stachyose, tri- and quadrupe saccharides, and cannot be digested by humans. They get passed along through your large intestine, where your normal flora (bacteria living in your colon) feast on them. (They do this anaerobically, fermenting the carbs, so that’s where the gas comes from.)
This is clearly why I went to med school.