The Gregorian calendar has a period of 400 years, or $400 \cdot 12$ months. Each cycle comprises $400 \cdot (365 - 28)$ days outside of February. February has 28 days in common years and 29 days in leap years, and there are 97 leap years, so the cycle comprises $97 \cdot 29 + (400 - 97) 28$ days in February. So the mean number of days per month is $400 \cdot (365 - 28) + 97 \cdot 29 + (400 - 97) 28$ all divided by $400 \cdot 12$, which is exactly $30.436875$. This is in fact the same thing as $365.2425 ÷ 12$ as suggested by achille hui, which makes sense considering that addition is commutative and associative, and I'm an idiot.