Avoiding bears and using common sense are good advice but I interpret the OP question as for what gun is best to kill a charging bear. Too late for avoiding, too late for common sense, too late for anything except “I’m here,
the bear’s there,
from here to there is much too close,
and the bear is rapidly decreasing the here to there.”
In a case like this I believe it’s safe to assume that the bear-er and the bear-ee were unaware of each other until too late to run or avoid on the part of the bear-ee, and the bear-er is startled into thinking the bear-ee is a threat (or a handy snack).
The National Park folk say pepper spray works almost every time. It’s that “almost” word which concerns me.
A 12 gauge loaded with slug or #4 shot is recommended, but do you carry a shotgun at the ready? Can one unlimber a shotgun before the bear-er is atop the bear-ee and the shotgunner-er finds the shotgun is of little use against the shotgun-ee?
It seems to me that the best defense is a big bore revolver, as big as one can get. I don’t believe follow up shots are going to be of much use, unless straight up from an inverted prone position into the bear’s belly.
One might consider, instead, some nice postal cards of Denali and checking on if there’s a good movie downtown and a nice restaurant.