Divide by 2 plus 7.
^^^ This, not necessarily a hard and fast rule but basically the right idea
In general, I reckon up to 10 years but it can probably be widened when you get a bit older, things like income, status etc.. come into play, within reason...
For example, Leonardo DiCaprio regularly gets grief for this - he's 46, his current girlfriend is 23... so a 23 year age gap, that causes social media criticism "she's half his age" etc...
Suppose instead Leo is 60 and starts dating a 37-year-old - same 23 year age gap, but no longer a young-early 20s that women get jealous about, fits the half age + 7 rule too, no one would care.
Ben Affleck, he's around Leo's age - 48, he was recently in a relationship with Ana de Armas (the lucky *******!) - she's 32... so a 16 year age gap... no one really cares about that age gap, it fits the rule.
I think the general principle of a larger gap being fine as the ages increase is pretty sound.