How much prestige does a gym lose when battling it?

I've been trying to keep an eye on this for a while now but I don't really understand how it's being worked out.

Obviously the number of Pokemon defeated affects how much prestige is lost. But what are the other factors and how much do they each affect it?

I feel like if you use only one you may get a bonus? What about if you're fighting with others? Does the level of the gym matter? What about if you retreat or lose all your Pokemon half way? Does swapping out Pokemon affect it at all?


Solution 1:

A Gym loses 500 prestige per pokemon defeated and 2000 prestige when the entire gym is defeated. This means that if there is only a single pokemon guarding a gym when you defeat it, it loses 2500 prestige.